From 0ffe8e0807ab9d84f0cb521d292ddd861f069ed4 Mon Sep 17 00:00:00 2001 From: benitav Date: Tue, 20 Feb 2024 11:53:07 +0200 Subject: [PATCH 01/39] Improve credntials templates --- .../lib/app_config_template.dart | 9 ++++++--- .../lib/app_config_template.dart | 9 ++++++--- .../lib/app_config_template.dart | 12 ++++++++---- .../lib/app_config_template.dart | 15 ++++++++------- 4 files changed, 28 insertions(+), 17 deletions(-) diff --git a/demos/supabase-anonymous-auth/lib/app_config_template.dart b/demos/supabase-anonymous-auth/lib/app_config_template.dart index bce37c5a..4e00929b 100644 --- a/demos/supabase-anonymous-auth/lib/app_config_template.dart +++ b/demos/supabase-anonymous-auth/lib/app_config_template.dart @@ -1,5 +1,8 @@ +/** + * Copy this template: `cp lib/app_config_template.dart lib/app_config.dart` + * Edit lib/app_config.dart and enter your Supabase and PowerSync project details. +*/ class AppConfig { - static const String supabaseUrl = 'https://jrimaqxlgrpjipgssldo.supabase.co'; - static const String supabaseAnonKey = - 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImpyaW1hcXhsZ3JwamlwZ3NzbGRvIiwicm9sZSI6ImFub24iLCJpYXQiOjE2OTE1ODY5MTAsImV4cCI6MjAwNzE2MjkxMH0.K-Qb-YFz0oVpLshUEezGU-Do-sX08zKqBzVccDoZp_Y'; + static const String supabaseUrl = 'https://foo.supabase.co'; + static const String supabaseAnonKey = 'foo'; } diff --git a/demos/supabase-edge-function-auth/lib/app_config_template.dart b/demos/supabase-edge-function-auth/lib/app_config_template.dart index bce37c5a..4e00929b 100644 --- a/demos/supabase-edge-function-auth/lib/app_config_template.dart +++ b/demos/supabase-edge-function-auth/lib/app_config_template.dart @@ -1,5 +1,8 @@ +/** + * Copy this template: `cp lib/app_config_template.dart lib/app_config.dart` + * Edit lib/app_config.dart and enter your Supabase and PowerSync project details. +*/ class AppConfig { - static const String supabaseUrl = 'https://jrimaqxlgrpjipgssldo.supabase.co'; - static const String supabaseAnonKey = - 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImpyaW1hcXhsZ3JwamlwZ3NzbGRvIiwicm9sZSI6ImFub24iLCJpYXQiOjE2OTE1ODY5MTAsImV4cCI6MjAwNzE2MjkxMH0.K-Qb-YFz0oVpLshUEezGU-Do-sX08zKqBzVccDoZp_Y'; + static const String supabaseUrl = 'https://foo.supabase.co'; + static const String supabaseAnonKey = 'foo'; } diff --git a/demos/supabase-simple-chat/lib/app_config_template.dart b/demos/supabase-simple-chat/lib/app_config_template.dart index 10dac15d..1ba0be62 100644 --- a/demos/supabase-simple-chat/lib/app_config_template.dart +++ b/demos/supabase-simple-chat/lib/app_config_template.dart @@ -1,6 +1,10 @@ +/** + * Copy this template: `cp lib/app_config_template.dart lib/app_config.dart` + * Edit lib/app_config.dart and enter your Supabase and PowerSync project details. +*/ class AppConfig { - static const String supabaseUrl = 'https://aaaaaaaaaaaa.supabase.co'; - static const String supabaseAnonKey = 'eyeyeyeyeyeye'; - static const String powersyncUrl = - 'https://65130c9db6679a3682ba380a.powersync.journeyapps.com'; + static const String supabaseUrl = 'https://foo.supabase.co'; + static const String supabaseAnonKey = 'foo'; + static const String powersyncUrl = 'https://foo.powersync.journeyapps.com'; } + diff --git a/demos/supabase-todolist/lib/app_config_template.dart b/demos/supabase-todolist/lib/app_config_template.dart index e38a6053..ef6eb246 100644 --- a/demos/supabase-todolist/lib/app_config_template.dart +++ b/demos/supabase-todolist/lib/app_config_template.dart @@ -1,9 +1,10 @@ +/** + * Copy this template: `cp lib/app_config_template.dart lib/app_config.dart` + * Edit lib/app_config.dart and enter your Supabase and PowerSync project details. +*/ class AppConfig { - static const String supabaseUrl = 'https://jrimaqxlgrpjipgssldo.supabase.co'; - static const String supabaseAnonKey = - 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImpyaW1hcXhsZ3JwamlwZ3NzbGRvIiwicm9sZSI6ImFub24iLCJpYXQiOjE2OTE1ODY5MTAsImV4cCI6MjAwNzE2MjkxMH0.K-Qb-YFz0oVpLshUEezGU-Do-sX08zKqBzVccDoZp_Y'; - static const String powersyncUrl = - 'https://64d392172a3c226cddbd5070.powersync.journeyapps.com'; - static const String supabaseStorageBucket = - ''; // Optional if you want to test out attachments + static const String supabaseUrl = 'https://foo.supabase.co'; + static const String supabaseAnonKey = 'foo'; + static const String powersyncUrl = 'https://foo.powersync.journeyapps.com'; + static const String supabaseStorageBucket = ''; // Optional. Only required when syncing attachments with Supabase Storage. See packages/powersync_attachments_helper. } From a3d616b1306e1dd4d13b3e308e7734b56bcf7a3c Mon Sep 17 00:00:00 2001 From: benitav Date: Tue, 20 Feb 2024 11:55:43 +0200 Subject: [PATCH 02/39] Format comments correctly --- demos/supabase-anonymous-auth/lib/app_config_template.dart | 6 ++---- .../lib/app_config_template.dart | 6 ++---- demos/supabase-simple-chat/lib/app_config_template.dart | 6 ++---- demos/supabase-todolist/lib/app_config_template.dart | 6 ++---- 4 files changed, 8 insertions(+), 16 deletions(-) diff --git a/demos/supabase-anonymous-auth/lib/app_config_template.dart b/demos/supabase-anonymous-auth/lib/app_config_template.dart index 4e00929b..41f9a7c8 100644 --- a/demos/supabase-anonymous-auth/lib/app_config_template.dart +++ b/demos/supabase-anonymous-auth/lib/app_config_template.dart @@ -1,7 +1,5 @@ -/** - * Copy this template: `cp lib/app_config_template.dart lib/app_config.dart` - * Edit lib/app_config.dart and enter your Supabase and PowerSync project details. -*/ +// Copy this template: `cp lib/app_config_template.dart lib/app_config.dart` +// Edit lib/app_config.dart and enter your Supabase and PowerSync project details. class AppConfig { static const String supabaseUrl = 'https://foo.supabase.co'; static const String supabaseAnonKey = 'foo'; diff --git a/demos/supabase-edge-function-auth/lib/app_config_template.dart b/demos/supabase-edge-function-auth/lib/app_config_template.dart index 4e00929b..41f9a7c8 100644 --- a/demos/supabase-edge-function-auth/lib/app_config_template.dart +++ b/demos/supabase-edge-function-auth/lib/app_config_template.dart @@ -1,7 +1,5 @@ -/** - * Copy this template: `cp lib/app_config_template.dart lib/app_config.dart` - * Edit lib/app_config.dart and enter your Supabase and PowerSync project details. -*/ +// Copy this template: `cp lib/app_config_template.dart lib/app_config.dart` +// Edit lib/app_config.dart and enter your Supabase and PowerSync project details. class AppConfig { static const String supabaseUrl = 'https://foo.supabase.co'; static const String supabaseAnonKey = 'foo'; diff --git a/demos/supabase-simple-chat/lib/app_config_template.dart b/demos/supabase-simple-chat/lib/app_config_template.dart index 1ba0be62..ee964d4f 100644 --- a/demos/supabase-simple-chat/lib/app_config_template.dart +++ b/demos/supabase-simple-chat/lib/app_config_template.dart @@ -1,7 +1,5 @@ -/** - * Copy this template: `cp lib/app_config_template.dart lib/app_config.dart` - * Edit lib/app_config.dart and enter your Supabase and PowerSync project details. -*/ +// Copy this template: `cp lib/app_config_template.dart lib/app_config.dart` +// Edit lib/app_config.dart and enter your Supabase and PowerSync project details. class AppConfig { static const String supabaseUrl = 'https://foo.supabase.co'; static const String supabaseAnonKey = 'foo'; diff --git a/demos/supabase-todolist/lib/app_config_template.dart b/demos/supabase-todolist/lib/app_config_template.dart index ef6eb246..bfb2e63e 100644 --- a/demos/supabase-todolist/lib/app_config_template.dart +++ b/demos/supabase-todolist/lib/app_config_template.dart @@ -1,7 +1,5 @@ -/** - * Copy this template: `cp lib/app_config_template.dart lib/app_config.dart` - * Edit lib/app_config.dart and enter your Supabase and PowerSync project details. -*/ +// Copy this template: `cp lib/app_config_template.dart lib/app_config.dart` +// Edit lib/app_config.dart and enter your Supabase and PowerSync project details. class AppConfig { static const String supabaseUrl = 'https://foo.supabase.co'; static const String supabaseAnonKey = 'foo'; From a00789911b4a8cf2084f7d41ca2ea5cc0e852558 Mon Sep 17 00:00:00 2001 From: benitav Date: Wed, 21 Feb 2024 08:54:42 +0200 Subject: [PATCH 03/39] Update demos/supabase-todolist/lib/app_config_template.dart --- demos/supabase-todolist/lib/app_config_template.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demos/supabase-todolist/lib/app_config_template.dart b/demos/supabase-todolist/lib/app_config_template.dart index bfb2e63e..be2e980e 100644 --- a/demos/supabase-todolist/lib/app_config_template.dart +++ b/demos/supabase-todolist/lib/app_config_template.dart @@ -4,5 +4,5 @@ class AppConfig { static const String supabaseUrl = 'https://foo.supabase.co'; static const String supabaseAnonKey = 'foo'; static const String powersyncUrl = 'https://foo.powersync.journeyapps.com'; - static const String supabaseStorageBucket = ''; // Optional. Only required when syncing attachments with Supabase Storage. See packages/powersync_attachments_helper. + static const String supabaseStorageBucket = ''; // Optional. Only required when syncing attachments and using Supabase Storage. See packages/powersync_attachments_helper. } From bcb3bea24ce903c3a6c3a77031b39d822a130906 Mon Sep 17 00:00:00 2001 From: Dominic Gunther Bauer <46312751+DominicGBauer@users.noreply.github.com> Date: Thu, 28 Mar 2024 17:37:53 +0200 Subject: [PATCH 04/39] chore: update podfile.lock (#67) * chore: update podfile.lock * docs: update readme * chore: uncomment platform * Update demos/supabase-todolist/README.md Co-authored-by: benitav * Update Readme instructions for both demo apps * Update demos/supabase-todolist/README.md Co-authored-by: benitav * Update demos/supabase-simple-chat/README.md Co-authored-by: benitav * chore: update podfile.lock --------- Co-authored-by: DominicGBauer Co-authored-by: benitav Co-authored-by: benitav --- demos/supabase-simple-chat/README.md | 10 ++++--- demos/supabase-simple-chat/ios/Podfile | 2 +- demos/supabase-simple-chat/ios/Podfile.lock | 32 ++++++++++----------- demos/supabase-todolist/README.md | 12 ++++---- demos/supabase-todolist/ios/Podfile | 2 +- demos/supabase-todolist/ios/Podfile.lock | 24 ++++++++-------- 6 files changed, 42 insertions(+), 40 deletions(-) diff --git a/demos/supabase-simple-chat/README.md b/demos/supabase-simple-chat/README.md index 6c892968..eeedeb20 100644 --- a/demos/supabase-simple-chat/README.md +++ b/demos/supabase-simple-chat/README.md @@ -4,8 +4,10 @@ Based on the Supabase Flutter tutorial to build a simple chat app: 3.43.1) + - sqlite3 (~> 3.45.1) - sqlite3/fts5 - sqlite3/perf-threadsafe - sqlite3/rtree @@ -64,15 +64,15 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: app_links: 5ef33d0d295a89d9d16bb81b0e3b0d5f70d6c875 - Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 - path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943 - shared_preferences_foundation: 5b919d13b803cadd15ed2dc053125c68730e5126 + Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 + path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c + shared_preferences_foundation: b4c3b4cddf1c21f02770737f147a3f5da9d39695 sign_in_with_apple: f3bf75217ea4c2c8b91823f225d70230119b8440 - sqlite3: e0a0623a33a20a47cb5921552aebc6e9e437dc91 - sqlite3_flutter_libs: 0d61e18fab1bed977dbd2d2fc76a726044ca00e7 - url_launcher_ios: 08a3dfac5fb39e8759aeb0abbd5d9480f30fc8b4 - webview_flutter_wkwebview: 2e2d318f21a5e036e2c3f26171342e95908bd60a + sqlite3: 73b7fc691fdc43277614250e04d183740cb15078 + sqlite3_flutter_libs: af0e8fe9bce48abddd1ffdbbf839db0302d72d80 + url_launcher_ios: bbd758c6e7f9fd7b5b1d4cde34d2b95fcce5e812 + webview_flutter_wkwebview: be0f0d33777f1bfd0c9fdcb594786704dbf65f36 -PODFILE CHECKSUM: 70d9d25280d0dd177a5f637cdb0f0b0b12c6a189 +PODFILE CHECKSUM: 7be2f5f74864d463a8ad433546ed1de7e0f29aef -COCOAPODS: 1.14.3 +COCOAPODS: 1.15.2 diff --git a/demos/supabase-todolist/README.md b/demos/supabase-todolist/README.md index b9524d48..3471f779 100644 --- a/demos/supabase-todolist/README.md +++ b/demos/supabase-todolist/README.md @@ -6,13 +6,13 @@ Demo app demonstrating use of the PowerSync SDK for Flutter together with Supaba # Running the app -Install the Flutter SDK, then: +Ensure you have [melos](https://melos.invertase.dev/~melos-latest/getting-started) installed. -```sh -cp lib/app_config_template.dart lib/app_config.dart -flutter pub get -flutter run -``` +1. `cd demos/supabase-todolist` +2. `melos bootstrap` +3. `cp lib/app_config_template.dart lib/app_config.dart` +4. Insert your Supabase and PowerSync project credentials into `lib/app_config.dart` (See instructions below) +5. `flutter run` # Set up Supabase Project diff --git a/demos/supabase-todolist/ios/Podfile b/demos/supabase-todolist/ios/Podfile index 656de635..e9f73048 100644 --- a/demos/supabase-todolist/ios/Podfile +++ b/demos/supabase-todolist/ios/Podfile @@ -1,5 +1,5 @@ # Uncomment this line to define a global platform for your project -# platform :ios, '12.0' +platform :ios, '12.0' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' diff --git a/demos/supabase-todolist/ios/Podfile.lock b/demos/supabase-todolist/ios/Podfile.lock index 67398eaf..56f60723 100644 --- a/demos/supabase-todolist/ios/Podfile.lock +++ b/demos/supabase-todolist/ios/Podfile.lock @@ -10,18 +10,18 @@ PODS: - shared_preferences_foundation (0.0.1): - Flutter - FlutterMacOS - - sqlite3 (3.44.0): - - sqlite3/common (= 3.44.0) - - sqlite3/common (3.44.0) - - sqlite3/fts5 (3.44.0): + - sqlite3 (3.45.1): + - sqlite3/common (= 3.45.1) + - sqlite3/common (3.45.1) + - sqlite3/fts5 (3.45.1): - sqlite3/common - - sqlite3/perf-threadsafe (3.44.0): + - sqlite3/perf-threadsafe (3.45.1): - sqlite3/common - - sqlite3/rtree (3.44.0): + - sqlite3/rtree (3.45.1): - sqlite3/common - sqlite3_flutter_libs (0.0.1): - Flutter - - sqlite3 (~> 3.44.0) + - sqlite3 (~> 3.45.1) - sqlite3/fts5 - sqlite3/perf-threadsafe - sqlite3/rtree @@ -59,14 +59,14 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: app_links: 5ef33d0d295a89d9d16bb81b0e3b0d5f70d6c875 - camera_avfoundation: 8b8d780bcfb6a4a02b0fbe2b4bd17b5b71946e68 + camera_avfoundation: 759172d1a77ae7be0de08fc104cfb79738b8a59e Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c shared_preferences_foundation: b4c3b4cddf1c21f02770737f147a3f5da9d39695 - sqlite3: 6e2d4a4879854d0ec86b476bf3c3e30870bac273 - sqlite3_flutter_libs: eb769059df0356dc52ddda040f09cacc9391a7cf + sqlite3: 73b7fc691fdc43277614250e04d183740cb15078 + sqlite3_flutter_libs: af0e8fe9bce48abddd1ffdbbf839db0302d72d80 url_launcher_ios: bbd758c6e7f9fd7b5b1d4cde34d2b95fcce5e812 -PODFILE CHECKSUM: 13e359f40c4925bcdf0c1bfa13aeba35011fde30 +PODFILE CHECKSUM: f7b3cb7384a2d5da4b22b090e1f632de7f377987 -COCOAPODS: 1.14.3 +COCOAPODS: 1.15.2 From 242636f0885c3edfbe190e4157226dfd07e2056f Mon Sep 17 00:00:00 2001 From: Dominic Gunther Bauer <46312751+DominicGBauer@users.noreply.github.com> Date: Wed, 3 Apr 2024 10:07:28 +0200 Subject: [PATCH 05/39] fix: attachment queue duplicating requests (#68) * chore: improve attachment queue * chore: update changelog * chore: pr feedback --------- Co-authored-by: DominicGBauer --- .../lib/attachments/queue.dart | 6 +- demos/supabase-todolist/pubspec.lock | 2 +- .../powersync_attachments_helper/CHANGELOG.md | 5 + .../powersync_attachments_helper/README.md | 8 +- .../example/getting_started.dart | 6 +- .../lib/src/attachments_queue.dart | 8 +- .../lib/src/attachments_service.dart | 41 +++++ .../lib/src/syncing_service.dart | 143 +++++------------- .../powersync_attachments_helper/pubspec.yaml | 8 +- 9 files changed, 105 insertions(+), 122 deletions(-) diff --git a/demos/supabase-todolist/lib/attachments/queue.dart b/demos/supabase-todolist/lib/attachments/queue.dart index 07a4b995..75273309 100644 --- a/demos/supabase-todolist/lib/attachments/queue.dart +++ b/demos/supabase-todolist/lib/attachments/queue.dart @@ -74,9 +74,9 @@ class PhotoAttachmentQueue extends AbstractAttachmentQueue { return results.map((row) => row['photo_id'] as String).toList(); }).listen((ids) async { List idsInQueue = await attachmentsService.getAttachmentIds(); - for (String id in ids) { - await syncingService.reconcileId(id, idsInQueue, fileExtension); - } + List relevantIds = + ids.where((element) => !idsInQueue.contains(element)).toList(); + syncingService.processIds(relevantIds, fileExtension); }); } } diff --git a/demos/supabase-todolist/pubspec.lock b/demos/supabase-todolist/pubspec.lock index a3e502c4..4e49469c 100644 --- a/demos/supabase-todolist/pubspec.lock +++ b/demos/supabase-todolist/pubspec.lock @@ -429,7 +429,7 @@ packages: path: "../../packages/powersync_attachments_helper" relative: true source: path - version: "0.2.1" + version: "0.3.0" realtime_client: dependency: transitive description: diff --git a/packages/powersync_attachments_helper/CHANGELOG.md b/packages/powersync_attachments_helper/CHANGELOG.md index 4f8ebdf8..a5a24e7d 100644 --- a/packages/powersync_attachments_helper/CHANGELOG.md +++ b/packages/powersync_attachments_helper/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.3.0 + +- BREAKING CHANGE: `reconcileId` has been removed in favour of `reconcileIds`. This will require a change to `watchIds` implementation which is shown in `example/getting_started.dart` +- Improved queue so that uploads, downloads and deletes do not happen multiple times + ## 0.2.1 - Added `onUploadError` as an optional function that can be set when setting up the queue to handle upload errors diff --git a/packages/powersync_attachments_helper/README.md b/packages/powersync_attachments_helper/README.md index a599887e..032319f7 100644 --- a/packages/powersync_attachments_helper/README.md +++ b/packages/powersync_attachments_helper/README.md @@ -62,7 +62,7 @@ class PhotoAttachmentQueue extends AbstractAttachmentQueue { // This watcher will handle adding items to the queue based on // a users table element receiving a photoId @override - StreamSubscription watchIds() { + StreamSubscription watchIds({String fileExtension = 'jpg'}) { return db.watch(''' SELECT photo_id FROM users WHERE photo_id IS NOT NULL @@ -70,9 +70,9 @@ class PhotoAttachmentQueue extends AbstractAttachmentQueue { return results.map((row) => row['photo_id'] as String).toList(); }).listen((ids) async { List idsInQueue = await attachmentsService.getAttachmentIds(); - for (String id in ids) { - await syncingService.reconcileId(id, idsInQueue); - } + List relevantIds = + ids.where((element) => !idsInQueue.contains(element)).toList(); + syncingService.processIds(relevantIds, fileExtension); }); } } diff --git a/packages/powersync_attachments_helper/example/getting_started.dart b/packages/powersync_attachments_helper/example/getting_started.dart index ed62f524..3f045b01 100644 --- a/packages/powersync_attachments_helper/example/getting_started.dart +++ b/packages/powersync_attachments_helper/example/getting_started.dart @@ -52,9 +52,9 @@ class PhotoAttachmentQueue extends AbstractAttachmentQueue { return results.map((row) => row['photo_id'] as String).toList(); }).listen((ids) async { List idsInQueue = await attachmentsService.getAttachmentIds(); - for (String id in ids) { - await syncingService.reconcileId(id, idsInQueue, fileExtension); - } + List relevantIds = + ids.where((element) => !idsInQueue.contains(element)).toList(); + syncingService.processIds(relevantIds, fileExtension); }); } } diff --git a/packages/powersync_attachments_helper/lib/src/attachments_queue.dart b/packages/powersync_attachments_helper/lib/src/attachments_queue.dart index e9e525ab..e8ed1965 100644 --- a/packages/powersync_attachments_helper/lib/src/attachments_queue.dart +++ b/packages/powersync_attachments_helper/lib/src/attachments_queue.dart @@ -67,9 +67,7 @@ abstract class AbstractAttachmentQueue { await localStorage.makeDir(await getStorageDirectory()); watchIds(); - syncingService.watchUploads(); - syncingService.watchDownloads(); - syncingService.watchDeletes(); + syncingService.watchAttachments(); db.statusStream.listen((status) { if (db.currentStatus.connected) { @@ -79,9 +77,7 @@ abstract class AbstractAttachmentQueue { } _trigger() async { - await syncingService.runDownloads(); - await syncingService.runDeletes(); - await syncingService.runUploads(); + await syncingService.runSync(); } /// Returns the local file path for the given filename, used to store in the database. diff --git a/packages/powersync_attachments_helper/lib/src/attachments_service.dart b/packages/powersync_attachments_helper/lib/src/attachments_service.dart index a337ad87..11fcdd37 100644 --- a/packages/powersync_attachments_helper/lib/src/attachments_service.dart +++ b/packages/powersync_attachments_helper/lib/src/attachments_service.dart @@ -59,6 +59,47 @@ class AttachmentsService { return updatedRecord; } + /// Save the attachments to the attachment queue. + Future saveAttachments(List attachments) async { + if (attachments.isEmpty) { + return; + } + List> ids = List.empty(growable: true); + + RegExp extractObjectValueRegEx = RegExp(r': (.*?)(?:,|$)'); + + // This adds a timestamp to the attachments and + // extracts the values from the attachment object + // e.g "foo: bar, baz: qux" => ["bar", "qux"] + // TODO: Extract value without needing to use regex + List> updatedRecords = attachments + .map((attachment) { + ids.add([attachment.id]); + return attachment.copyWith( + timestamp: DateTime.now().millisecondsSinceEpoch, + ); + }) + .toList() + .map((attachment) { + return extractObjectValueRegEx + .allMatches(attachment.toString().replaceAll('}', '')) + .map((match) => match.group(1)) + .toList(); + }) + .toList(); + + await db.executeBatch(''' + INSERT OR REPLACE INTO $table + (id, filename, local_uri, media_type, size, timestamp, state) VALUES (?, ?, ?, ?, ?, ?, ?) + ''', updatedRecords); + + await db.executeBatch(''' + DELETE FROM $table WHERE id = ? + ''', ids); + + return; + } + /// Get all the ID's of attachments in the attachment queue. Future> getAttachmentIds() async { ResultSet results = diff --git a/packages/powersync_attachments_helper/lib/src/syncing_service.dart b/packages/powersync_attachments_helper/lib/src/syncing_service.dart index 853a1504..baaf4d58 100644 --- a/packages/powersync_attachments_helper/lib/src/syncing_service.dart +++ b/packages/powersync_attachments_helper/lib/src/syncing_service.dart @@ -19,6 +19,7 @@ class SyncingService { onDownloadError; final Future Function(Attachment attachment, Object exception)? onUploadError; + bool isProcessing = false; SyncingService(this.db, this.remoteStorage, this.localStorage, this.attachmentsService, this.getLocalUri, @@ -103,139 +104,79 @@ class SyncingService { } } - /// Function to manually run downloads for attachments marked for download - /// in the attachment queue. - /// Once a an attachment marked for download is found it will initiate a - /// download of the file to local storage. - StreamSubscription watchDownloads() { - log.info('Watching downloads...'); - return db.watch(''' - SELECT * FROM ${attachmentsService.table} - WHERE state = ${AttachmentState.queuedDownload.index} - ''').map((results) { - return results.map((row) => Attachment.fromRow(row)); - }).listen((attachments) async { - for (Attachment attachment in attachments) { - log.info('Downloading ${attachment.filename}'); - await downloadAttachment(attachment); - } - }); - } + /// Handle downloading, uploading or deleting of attachments + Future handleSync(Iterable attachments) async { + if (isProcessing == true) { + return; + } - /// Watcher for attachments marked for download in the attachment queue. - /// Once a an attachment marked for download is found it will initiate a - /// download of the file to local storage. - Future runDownloads() async { - List attachments = await db.execute(''' - SELECT * FROM ${attachmentsService.table} - WHERE state = ${AttachmentState.queuedDownload.index} - ''').then((results) { - return results.map((row) => Attachment.fromRow(row)).toList(); - }); + isProcessing = true; for (Attachment attachment in attachments) { - log.info('Downloading ${attachment.filename}'); - await downloadAttachment(attachment); - } - } - - /// Watcher for attachments marked for upload in the attachment queue. - /// Once a an attachment marked for upload is found it will initiate an - /// upload of the file to remote storage. - StreamSubscription watchUploads() { - log.info('Watching uploads...'); - return db.watch(''' - SELECT * FROM ${attachmentsService.table} - WHERE local_uri IS NOT NULL - AND state = ${AttachmentState.queuedUpload.index} - ''').map((results) { - return results.map((row) => Attachment.fromRow(row)); - }).listen((attachments) async { - for (Attachment attachment in attachments) { + if (AttachmentState.queuedDownload.index == attachment.state) { + log.info('Downloading ${attachment.filename}'); + await downloadAttachment(attachment); + } + if (AttachmentState.queuedUpload.index == attachment.state) { log.info('Uploading ${attachment.filename}'); await uploadAttachment(attachment); } - }); - } - - /// Function to manually run uploads for attachments marked for upload - /// in the attachment queue. - /// Once a an attachment marked for deletion is found it will initiate an - /// upload of the file to remote storage - Future runUploads() async { - List attachments = await db.execute(''' - SELECT * FROM ${attachmentsService.table} - WHERE local_uri IS NOT NULL - AND state = ${AttachmentState.queuedUpload.index} - ''').then((results) { - return results.map((row) => Attachment.fromRow(row)).toList(); - }); - - for (Attachment attachment in attachments) { - log.info('Uploading ${attachment.filename}'); - await uploadAttachment(attachment); + if (AttachmentState.queuedDelete.index == attachment.state) { + log.info('Deleting ${attachment.filename}'); + await deleteAttachment(attachment); + } } + + isProcessing = false; } - /// Watcher for attachments marked for deletion in the attachment queue. - /// Once a an attachment marked for deletion is found it will initiate remote - /// and local deletions of the file. - StreamSubscription watchDeletes() { - log.info('Watching deletes...'); + /// Watcher for changes to attachments table + /// Once a change is detected it will initiate a sync of the attachments + StreamSubscription watchAttachments() { + log.info('Watching attachments...'); return db.watch(''' SELECT * FROM ${attachmentsService.table} - WHERE state = ${AttachmentState.queuedDelete.index} + WHERE state != ${AttachmentState.archived.index} ''').map((results) { return results.map((row) => Attachment.fromRow(row)); }).listen((attachments) async { - for (Attachment attachment in attachments) { - log.info('Deleting ${attachment.filename}'); - await deleteAttachment(attachment); - } + await handleSync(attachments); }); } - /// Function to manually run deletes for attachments marked for deletion - /// in the attachment queue. - /// Once a an attachment marked for deletion is found it will initiate remote - /// and local deletions of the file. - Future runDeletes() async { + /// Run the sync process on all attachments + Future runSync() async { List attachments = await db.execute(''' SELECT * FROM ${attachmentsService.table} - WHERE state = ${AttachmentState.queuedDelete.index} + WHERE state != ${AttachmentState.archived.index} ''').then((results) { return results.map((row) => Attachment.fromRow(row)).toList(); }); - for (Attachment attachment in attachments) { - log.info('Deleting ${attachment.filename}'); - await deleteAttachment(attachment); - } + await handleSync(attachments); } - /// Reconcile an ID with ID's in the attachment queue. - /// If the ID is not in the queue, but the file exists locally then it is - /// in local and remote storage. - /// If the ID is in the queue, but the file does not exist locally then it is - /// marked for download. - reconcileId(String id, List idsInQueue, String fileExtension) async { - bool idIsInQueue = idsInQueue.contains(id); + /// Process ID's to be included in the attachment queue. + processIds(List ids, String fileExtension) async { + List attachments = List.empty(growable: true); - String path = await getLocalUri('$id.$fileExtension'); - File file = File(path); - bool fileExists = await file.exists(); + for (String id in ids) { + String path = await getLocalUri('$id.$fileExtension'); + File file = File(path); + bool fileExists = await file.exists(); - if (!idIsInQueue) { if (fileExists) { log.info('ignore file $id.$fileExtension as it already exists'); return; } + log.info('Adding $id to queue'); - return await attachmentsService.saveAttachment(Attachment( - id: id, - filename: '$id.$fileExtension', - state: AttachmentState.queuedDownload.index, - )); + attachments.add(Attachment( + id: id, + filename: '$id.$fileExtension', + state: AttachmentState.queuedDownload.index)); } + + await attachmentsService.saveAttachments(attachments); } } diff --git a/packages/powersync_attachments_helper/pubspec.yaml b/packages/powersync_attachments_helper/pubspec.yaml index b216afae..70666b7c 100644 --- a/packages/powersync_attachments_helper/pubspec.yaml +++ b/packages/powersync_attachments_helper/pubspec.yaml @@ -1,6 +1,6 @@ name: powersync_attachments_helper description: A helper library for handling attachments when using PowerSync. -version: 0.2.1 +version: 0.3.0 repository: https://github.com/powersync-ja/powersync.dart homepage: https://www.powersync.com/ environment: @@ -10,14 +10,14 @@ dependencies: flutter: sdk: flutter - powersync: ^1.1.0 + powersync: ^1.2.2 logging: ^1.2.0 sqlite_async: ^0.6.0 - path_provider: ^2.1.1 + path_provider: ^2.1.2 dev_dependencies: lints: ^3.0.0 - test: ^1.25.0 + test: ^1.25.2 platforms: android: From fbb7cb43a9b4ac4c4c02aaecbc731b9a546036f5 Mon Sep 17 00:00:00 2001 From: Dominic Gunther Bauer <46312751+DominicGBauer@users.noreply.github.com> Date: Mon, 8 Apr 2024 15:12:30 +0200 Subject: [PATCH 06/39] chore: add crud throttle option (#71) * chore(powersync): add crud throttle to connect * chore(powersync): add crud throttle to connect --------- Co-authored-by: DominicGBauer --- demos/supabase-todolist/pubspec.lock | 4 ++-- packages/powersync/lib/src/powersync_database.dart | 11 ++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/demos/supabase-todolist/pubspec.lock b/demos/supabase-todolist/pubspec.lock index 4e49469c..41b4c4f7 100644 --- a/demos/supabase-todolist/pubspec.lock +++ b/demos/supabase-todolist/pubspec.lock @@ -551,10 +551,10 @@ packages: dependency: "direct main" description: name: sqlite_async - sha256: "609a8405b8b608ac396dd7f478ed42e230c496eb38fe53dd97e9c592e1cd5cda" + sha256: "139c8f1085132d0941b925efacb4fa0fed9ee40d624739cc26a051dbc36bf727" url: "https://pub.dev" source: hosted - version: "0.6.0" + version: "0.6.1" stack_trace: dependency: transitive description: diff --git a/packages/powersync/lib/src/powersync_database.dart b/packages/powersync/lib/src/powersync_database.dart index 239c7c3b..3445fd2b 100644 --- a/packages/powersync/lib/src/powersync_database.dart +++ b/packages/powersync/lib/src/powersync_database.dart @@ -184,7 +184,12 @@ class PowerSyncDatabase with SqliteQueries implements SqliteConnection { /// The connection is automatically re-opened if it fails for any reason. /// /// Status changes are reported on [statusStream]. - Future connect({required PowerSyncBackendConnector connector}) async { + Future connect( + {required PowerSyncBackendConnector connector, + + /// Throttle time between CRUD operations + /// Defaults to 10 milliseconds. + Duration crudThrottleTime = const Duration(milliseconds: 10)}) async { await initialize(); // Disconnect if connected @@ -212,8 +217,8 @@ class PowerSyncDatabase with SqliteQueries implements SqliteConnection { }); } else if (action == 'init') { SendPort port = data[1]; - var throttled = UpdateNotification.throttleStream( - updates, const Duration(milliseconds: 10)); + var throttled = + UpdateNotification.throttleStream(updates, crudThrottleTime); updateSubscription = throttled.listen((event) { port.send(['update']); }); From 2a2b2abd27692e085f385dffd8942cfc0b52bf9a Mon Sep 17 00:00:00 2001 From: Dominic Gunther Bauer <46312751+DominicGBauer@users.noreply.github.com> Date: Wed, 10 Apr 2024 14:46:33 +0200 Subject: [PATCH 07/39] chore(powersync): update version (#72) Co-authored-by: DominicGBauer --- demos/supabase-anonymous-auth/pubspec.lock | 2 +- demos/supabase-edge-function-auth/pubspec.lock | 2 +- demos/supabase-simple-chat/pubspec.lock | 2 +- demos/supabase-todolist/pubspec.lock | 2 +- packages/powersync/CHANGELOG.md | 4 ++++ packages/powersync/pubspec.yaml | 2 +- 6 files changed, 9 insertions(+), 5 deletions(-) diff --git a/demos/supabase-anonymous-auth/pubspec.lock b/demos/supabase-anonymous-auth/pubspec.lock index 4379f0f5..d8d4d125 100644 --- a/demos/supabase-anonymous-auth/pubspec.lock +++ b/demos/supabase-anonymous-auth/pubspec.lock @@ -326,7 +326,7 @@ packages: path: "../../packages/powersync" relative: true source: path - version: "1.2.2" + version: "1.3.0" realtime_client: dependency: transitive description: diff --git a/demos/supabase-edge-function-auth/pubspec.lock b/demos/supabase-edge-function-auth/pubspec.lock index 4379f0f5..d8d4d125 100644 --- a/demos/supabase-edge-function-auth/pubspec.lock +++ b/demos/supabase-edge-function-auth/pubspec.lock @@ -326,7 +326,7 @@ packages: path: "../../packages/powersync" relative: true source: path - version: "1.2.2" + version: "1.3.0" realtime_client: dependency: transitive description: diff --git a/demos/supabase-simple-chat/pubspec.lock b/demos/supabase-simple-chat/pubspec.lock index 3d9e829f..7cc6f802 100644 --- a/demos/supabase-simple-chat/pubspec.lock +++ b/demos/supabase-simple-chat/pubspec.lock @@ -358,7 +358,7 @@ packages: path: "../../packages/powersync" relative: true source: path - version: "1.2.2" + version: "1.3.0" realtime_client: dependency: transitive description: diff --git a/demos/supabase-todolist/pubspec.lock b/demos/supabase-todolist/pubspec.lock index 41b4c4f7..b17411ef 100644 --- a/demos/supabase-todolist/pubspec.lock +++ b/demos/supabase-todolist/pubspec.lock @@ -422,7 +422,7 @@ packages: path: "../../packages/powersync" relative: true source: path - version: "1.2.2" + version: "1.3.0" powersync_attachments_helper: dependency: "direct main" description: diff --git a/packages/powersync/CHANGELOG.md b/packages/powersync/CHANGELOG.md index 1a4b80e5..3e6e89c1 100644 --- a/packages/powersync/CHANGELOG.md +++ b/packages/powersync/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.3.0 + +- Add `crudThrottleTime` option to arguments when running `PowerSyncDatabase.connect` to set throttle time for crud operations. + ## 1.2.2 - Deprecate DevConnector and related diff --git a/packages/powersync/pubspec.yaml b/packages/powersync/pubspec.yaml index 6c32feff..5b9f44d7 100644 --- a/packages/powersync/pubspec.yaml +++ b/packages/powersync/pubspec.yaml @@ -1,5 +1,5 @@ name: powersync -version: 1.2.2 +version: 1.3.0 homepage: https://powersync.com repository: https://github.com/powersync-ja/powersync.dart description: PowerSync Flutter SDK - keep PostgreSQL databases in sync with on-device SQLite databases. From 21a28e951252d26ee78381feb7382028011fb13b Mon Sep 17 00:00:00 2001 From: Ralf Kistner Date: Thu, 11 Apr 2024 13:39:56 +0200 Subject: [PATCH 08/39] sqlite_async v0.6.1 --- packages/powersync/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/powersync/pubspec.yaml b/packages/powersync/pubspec.yaml index 5b9f44d7..820f9d7b 100644 --- a/packages/powersync/pubspec.yaml +++ b/packages/powersync/pubspec.yaml @@ -10,7 +10,7 @@ dependencies: flutter: sdk: flutter - sqlite_async: ^0.6.0 + sqlite_async: ^0.6.1 sqlite3_flutter_libs: ^0.5.15 http: ^1.1.0 uuid: ^4.2.0 From 90cff10d0230646a3253f70aab1d5d593cb9b049 Mon Sep 17 00:00:00 2001 From: Ralf Kistner Date: Thu, 11 Apr 2024 13:54:01 +0200 Subject: [PATCH 09/39] Improve streaming_sync_tests. --- .../powersync/test/streaming_sync_test.dart | 21 ++--- packages/powersync/test/test_server.dart | 79 +++++++++++++------ 2 files changed, 60 insertions(+), 40 deletions(-) diff --git a/packages/powersync/test/streaming_sync_test.dart b/packages/powersync/test/streaming_sync_test.dart index aff9c71c..6cd64ff6 100644 --- a/packages/powersync/test/streaming_sync_test.dart +++ b/packages/powersync/test/streaming_sync_test.dart @@ -44,12 +44,8 @@ void main() { var server = await createServer(); credentialsCallback() async { - final endpoint = 'http://${server.address.host}:${server.port}'; return PowerSyncCredentials( - endpoint: endpoint, - token: 'token', - userId: 'u1', - expiresAt: DateTime.now()); + endpoint: server.endpoint, token: 'token'); } final pdb = await setupPowerSync(path: path); @@ -59,12 +55,12 @@ void main() { await Future.delayed(Duration(milliseconds: random.nextInt(100))); if (random.nextBool()) { - server.close(force: true).ignore(); + server.close(); } await pdb.close(); - server.close(force: true).ignore(); + server.close(); } }); @@ -81,18 +77,13 @@ void main() { // [PowerSync] WARNING: 2023-06-29 16:10:17.667537: Sync Isolate error // [Connection closed while receiving data, #0 IOClient.send. (package:http/src/io_client.dart:76:13) - HttpServer? server; + TestServer? server; credentialsCallback() async { if (server == null) { throw AssertionError('No active server'); } - final endpoint = 'http://${server.address.host}:${server.port}'; - return PowerSyncCredentials( - endpoint: endpoint, - token: 'token', - userId: 'u1', - expiresAt: DateTime.now()); + return PowerSyncCredentials(endpoint: server.endpoint, token: 'token'); } final pdb = await setupPowerSync(path: path); @@ -107,7 +98,7 @@ void main() { // 2ms: HttpException: HttpServer is not bound to a socket // 20ms: Connection closed while receiving data await Future.delayed(Duration(milliseconds: 20)); - server.close(force: true).ignore(); + server.close(); } await pdb.close(); }); diff --git a/packages/powersync/test/test_server.dart b/packages/powersync/test/test_server.dart index c85101a9..2b9ac8b6 100644 --- a/packages/powersync/test/test_server.dart +++ b/packages/powersync/test/test_server.dart @@ -1,18 +1,67 @@ import 'dart:async'; import 'dart:convert' as convert; import 'dart:io'; +import 'dart:math'; import 'package:http/http.dart' show ByteStream; import 'package:shelf/shelf.dart'; import 'package:shelf/shelf_io.dart' as shelf_io; import 'package:shelf_router/shelf_router.dart'; -Future createServer() async { - var app = Router(); +class TestServer { + late HttpServer server; + Router app = Router(); + int connectionCount = 0; + int maxConnectionCount = 0; + int tokenExpiresIn; - app.post('/sync/stream', handleSyncStream); - // Open on an arbitrary open port - var server = await shelf_io.serve(app.call, 'localhost', 0); + TestServer({this.tokenExpiresIn = 65}); + + Future init() async { + app.post('/sync/stream', handleSyncStream); + // Open on an arbitrary open port + server = await shelf_io.serve(app.call, 'localhost', 0); + } + + String get endpoint { + return 'http://${server.address.host}:${server.port}'; + } + + Future handleSyncStream(Request request) async { + connectionCount += 1; + maxConnectionCount = max(connectionCount, maxConnectionCount); + + stream() async* { + try { + var blob = "*" * 5000; + for (var i = 0; i < 50; i++) { + yield {"token_expires_in": tokenExpiresIn, "blob": blob}; + await Future.delayed(Duration(microseconds: 1)); + } + } finally { + connectionCount -= 1; + } + } + + return Response.ok( + encodeNdjson(stream()), + headers: { + 'Content-Type': 'application/x-ndjson', + }, + context: { + 'shelf.io.buffer_output': false, + }, + ); + } + + void close() { + server.close(force: true).ignore(); + } +} + +Future createServer() async { + var server = TestServer(); + await server.init(); return server; } @@ -22,23 +71,3 @@ ByteStream encodeNdjson(Stream jsonInput) { final byteInput = stringInput.transform(convert.utf8.encoder); return ByteStream(byteInput); } - -Future handleSyncStream(Request request) async { - stream() async* { - var blob = "*" * 5000; - for (var i = 0; i < 50; i++) { - yield {"token_expires_in": 5, "blob": blob}; - await Future.delayed(Duration(microseconds: 1)); - } - } - - return Response.ok( - encodeNdjson(stream()), - headers: { - 'Content-Type': 'application/x-ndjson', - }, - context: { - 'shelf.io.buffer_output': false, - }, - ); -} From 58fa056bc6bc1c63dfa88156e0ec92b7b89ef043 Mon Sep 17 00:00:00 2001 From: Ralf Kistner Date: Thu, 11 Apr 2024 13:54:34 +0200 Subject: [PATCH 10/39] Add failing test. --- .../powersync/test/streaming_sync_test.dart | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/packages/powersync/test/streaming_sync_test.dart b/packages/powersync/test/streaming_sync_test.dart index 6cd64ff6..e86da411 100644 --- a/packages/powersync/test/streaming_sync_test.dart +++ b/packages/powersync/test/streaming_sync_test.dart @@ -102,5 +102,43 @@ void main() { } await pdb.close(); }); + + test('multiple connect calls', () async { + // Test repeatedly creating new PowerSync connections, then disconnect + // and close the connection. + final random = Random(); + var server = await createServer(); + + credentialsCallback() async { + return PowerSyncCredentials(endpoint: server.endpoint, token: 'token'); + } + + final pdb = await setupPowerSync(path: path); + pdb.retryDelay = Duration(milliseconds: 5000); + var connector = TestConnector(credentialsCallback); + pdb.connect(connector: connector); + pdb.connect(connector: connector); + + final watch = Stopwatch()..start(); + + // Wait for at least one connection + while (server.connectionCount < 1 && watch.elapsedMilliseconds < 500) { + await Future.delayed(Duration(milliseconds: random.nextInt(10))); + } + // Give some time for a second connection if any + await Future.delayed(Duration(milliseconds: random.nextInt(50))); + + await pdb.close(); + + // Give some time for connections to close + while (server.connectionCount != 0 && watch.elapsedMilliseconds < 1000) { + await Future.delayed(Duration(milliseconds: random.nextInt(10))); + } + + expect(server.connectionCount, equals(0)); + expect(server.maxConnectionCount, equals(1)); + + server.close(); + }); }); } From f32b30ccde88d7f75a39e5c2eb721206e93c5ab7 Mon Sep 17 00:00:00 2001 From: Ralf Kistner Date: Thu, 11 Apr 2024 13:58:44 +0200 Subject: [PATCH 11/39] Fix issue when calling connect() multiple times. --- packages/powersync/lib/src/powersync_database.dart | 11 +++++++++++ packages/powersync/test/streaming_sync_test.dart | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/powersync/lib/src/powersync_database.dart b/packages/powersync/lib/src/powersync_database.dart index 3445fd2b..434d3c22 100644 --- a/packages/powersync/lib/src/powersync_database.dart +++ b/packages/powersync/lib/src/powersync_database.dart @@ -3,6 +3,7 @@ import 'dart:isolate'; import 'package:logging/logging.dart'; import 'package:powersync/src/log_internal.dart'; +import 'package:sqlite_async/mutex.dart'; import 'package:sqlite_async/sqlite3.dart' as sqlite; import 'package:sqlite_async/sqlite_async.dart'; @@ -69,6 +70,9 @@ class PowerSyncDatabase with SqliteQueries implements SqliteConnection { /// null when disconnected, present when connecting or connected AbortController? _disconnecter; + /// Use to prevent multiple connections from being opened concurrently + final Mutex _connectMutex = Mutex(); + /// The Logger used by this [PowerSyncDatabase]. /// /// The default is [autoLogger], which logs to the console in debug builds. @@ -190,6 +194,13 @@ class PowerSyncDatabase with SqliteQueries implements SqliteConnection { /// Throttle time between CRUD operations /// Defaults to 10 milliseconds. Duration crudThrottleTime = const Duration(milliseconds: 10)}) async { + _connectMutex.lock(() => + _connect(connector: connector, crudThrottleTime: crudThrottleTime)); + } + + Future _connect( + {required PowerSyncBackendConnector connector, + required Duration crudThrottleTime}) async { await initialize(); // Disconnect if connected diff --git a/packages/powersync/test/streaming_sync_test.dart b/packages/powersync/test/streaming_sync_test.dart index e86da411..85d647a5 100644 --- a/packages/powersync/test/streaming_sync_test.dart +++ b/packages/powersync/test/streaming_sync_test.dart @@ -104,8 +104,8 @@ void main() { }); test('multiple connect calls', () async { - // Test repeatedly creating new PowerSync connections, then disconnect - // and close the connection. + // Test calling connect() multiple times. + // We check that this does not cause multiple connections to be opened concurrently. final random = Random(); var server = await createServer(); From ccaf293c10af24842dd4b4e4d5e3069c6c5b83a2 Mon Sep 17 00:00:00 2001 From: Ralf Kistner Date: Thu, 11 Apr 2024 14:01:13 +0200 Subject: [PATCH 12/39] Fix lint issue. --- packages/powersync/test/streaming_sync_test.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/powersync/test/streaming_sync_test.dart b/packages/powersync/test/streaming_sync_test.dart index 85d647a5..adda1399 100644 --- a/packages/powersync/test/streaming_sync_test.dart +++ b/packages/powersync/test/streaming_sync_test.dart @@ -1,5 +1,4 @@ import 'dart:async'; -import 'dart:io'; import 'dart:math'; import 'package:powersync/powersync.dart'; From 1177101ab4d58eaf9b89c390c04d20e4398a66e1 Mon Sep 17 00:00:00 2001 From: Dominic Gunther Bauer <46312751+DominicGBauer@users.noreply.github.com> Date: Thu, 11 Apr 2024 14:35:00 +0200 Subject: [PATCH 13/39] chore(attachments): minor improvements and fix loop (#70) * chore(attachments): minor improvements * docs: update changelog * chore: pr reverts --------- Co-authored-by: DominicGBauer --- demos/supabase-todolist/pubspec.lock | 2 +- .../powersync_attachments_helper/CHANGELOG.md | 6 +++++ .../lib/src/attachments_queue.dart | 7 +++++- .../lib/src/attachments_service.dart | 4 ---- .../lib/src/syncing_service.dart | 24 +++++++++++++++++-- .../powersync_attachments_helper/pubspec.yaml | 4 ++-- 6 files changed, 37 insertions(+), 10 deletions(-) diff --git a/demos/supabase-todolist/pubspec.lock b/demos/supabase-todolist/pubspec.lock index b17411ef..0e231357 100644 --- a/demos/supabase-todolist/pubspec.lock +++ b/demos/supabase-todolist/pubspec.lock @@ -429,7 +429,7 @@ packages: path: "../../packages/powersync_attachments_helper" relative: true source: path - version: "0.3.0" + version: "0.3.1" realtime_client: dependency: transitive description: diff --git a/packages/powersync_attachments_helper/CHANGELOG.md b/packages/powersync_attachments_helper/CHANGELOG.md index a5a24e7d..1028766a 100644 --- a/packages/powersync_attachments_helper/CHANGELOG.md +++ b/packages/powersync_attachments_helper/CHANGELOG.md @@ -1,3 +1,9 @@ +## 0.3.1 + +- Add periodic syncing and deleting of attachments +- Remove unnecessary delete +- Fix loop + ## 0.3.0 - BREAKING CHANGE: `reconcileId` has been removed in favour of `reconcileIds`. This will require a change to `watchIds` implementation which is shown in `example/getting_started.dart` diff --git a/packages/powersync_attachments_helper/lib/src/attachments_queue.dart b/packages/powersync_attachments_helper/lib/src/attachments_queue.dart index e8ed1965..f2f8e742 100644 --- a/packages/powersync_attachments_helper/lib/src/attachments_queue.dart +++ b/packages/powersync_attachments_helper/lib/src/attachments_queue.dart @@ -33,6 +33,10 @@ abstract class AbstractAttachmentQueue { /// Return true if you want to ignore attachment Future Function(Attachment attachment, Object exception)? onUploadError; + /// Interval in minutes to periodically run [syncingService.startPeriodicSync] + /// Default is 5 minutes + int intervalInMinutes; + AbstractAttachmentQueue( {required this.db, required this.remoteStorage, @@ -40,7 +44,7 @@ abstract class AbstractAttachmentQueue { this.attachmentsQueueTableName = defaultAttachmentsQueueTableName, this.onDownloadError, this.onUploadError, - performInitialSync = true}) { + this.intervalInMinutes = 5}) { attachmentsService = AttachmentsService( db, localStorage, attachmentDirectoryName, attachmentsQueueTableName); syncingService = SyncingService( @@ -68,6 +72,7 @@ abstract class AbstractAttachmentQueue { watchIds(); syncingService.watchAttachments(); + syncingService.startPeriodicSync(intervalInMinutes); db.statusStream.listen((status) { if (db.currentStatus.connected) { diff --git a/packages/powersync_attachments_helper/lib/src/attachments_service.dart b/packages/powersync_attachments_helper/lib/src/attachments_service.dart index 11fcdd37..6f9b8da4 100644 --- a/packages/powersync_attachments_helper/lib/src/attachments_service.dart +++ b/packages/powersync_attachments_helper/lib/src/attachments_service.dart @@ -93,10 +93,6 @@ class AttachmentsService { (id, filename, local_uri, media_type, size, timestamp, state) VALUES (?, ?, ?, ?, ?, ?, ?) ''', updatedRecords); - await db.executeBatch(''' - DELETE FROM $table WHERE id = ? - ''', ids); - return; } diff --git a/packages/powersync_attachments_helper/lib/src/syncing_service.dart b/packages/powersync_attachments_helper/lib/src/syncing_service.dart index baaf4d58..ec94ff8e 100644 --- a/packages/powersync_attachments_helper/lib/src/syncing_service.dart +++ b/packages/powersync_attachments_helper/lib/src/syncing_service.dart @@ -20,6 +20,7 @@ class SyncingService { final Future Function(Attachment attachment, Object exception)? onUploadError; bool isProcessing = false; + Timer? timer; SyncingService(this.db, this.remoteStorage, this.localStorage, this.attachmentsService, this.getLocalUri, @@ -166,8 +167,7 @@ class SyncingService { bool fileExists = await file.exists(); if (fileExists) { - log.info('ignore file $id.$fileExtension as it already exists'); - return; + continue; } log.info('Adding $id to queue'); @@ -179,4 +179,24 @@ class SyncingService { await attachmentsService.saveAttachments(attachments); } + + /// Delete attachments which have been archived + deleteArchivedAttachments() async { + await db.execute(''' + DELETE FROM ${attachmentsService.table} + WHERE state = ${AttachmentState.archived.index} + '''); + } + + /// Periodically sync attachments and delete archived attachments + void startPeriodicSync(int intervalInMinutes) { + timer?.cancel(); + + timer = Timer.periodic(Duration(minutes: intervalInMinutes), (timer) { + log.info('Syncing attachments'); + runSync(); + log.info('Deleting archived attachments'); + deleteArchivedAttachments(); + }); + } } diff --git a/packages/powersync_attachments_helper/pubspec.yaml b/packages/powersync_attachments_helper/pubspec.yaml index 70666b7c..bb599186 100644 --- a/packages/powersync_attachments_helper/pubspec.yaml +++ b/packages/powersync_attachments_helper/pubspec.yaml @@ -1,6 +1,6 @@ name: powersync_attachments_helper description: A helper library for handling attachments when using PowerSync. -version: 0.3.0 +version: 0.3.1 repository: https://github.com/powersync-ja/powersync.dart homepage: https://www.powersync.com/ environment: @@ -12,7 +12,7 @@ dependencies: powersync: ^1.2.2 logging: ^1.2.0 - sqlite_async: ^0.6.0 + sqlite_async: ^0.6.1 path_provider: ^2.1.2 dev_dependencies: From 24931d6930d5043977dc00564cc56f6203eb5219 Mon Sep 17 00:00:00 2001 From: Ralf Kistner Date: Thu, 11 Apr 2024 14:36:47 +0200 Subject: [PATCH 14/39] v1.3.1 --- demos/supabase-anonymous-auth/pubspec.lock | 6 +++--- demos/supabase-edge-function-auth/pubspec.lock | 6 +++--- demos/supabase-simple-chat/pubspec.lock | 6 +++--- demos/supabase-todolist/pubspec.lock | 2 +- packages/powersync/CHANGELOG.md | 4 ++++ packages/powersync/pubspec.yaml | 2 +- 6 files changed, 15 insertions(+), 11 deletions(-) diff --git a/demos/supabase-anonymous-auth/pubspec.lock b/demos/supabase-anonymous-auth/pubspec.lock index d8d4d125..940adbbc 100644 --- a/demos/supabase-anonymous-auth/pubspec.lock +++ b/demos/supabase-anonymous-auth/pubspec.lock @@ -326,7 +326,7 @@ packages: path: "../../packages/powersync" relative: true source: path - version: "1.3.0" + version: "1.3.1" realtime_client: dependency: transitive description: @@ -448,10 +448,10 @@ packages: dependency: "direct main" description: name: sqlite_async - sha256: "609a8405b8b608ac396dd7f478ed42e230c496eb38fe53dd97e9c592e1cd5cda" + sha256: "139c8f1085132d0941b925efacb4fa0fed9ee40d624739cc26a051dbc36bf727" url: "https://pub.dev" source: hosted - version: "0.6.0" + version: "0.6.1" stack_trace: dependency: transitive description: diff --git a/demos/supabase-edge-function-auth/pubspec.lock b/demos/supabase-edge-function-auth/pubspec.lock index d8d4d125..940adbbc 100644 --- a/demos/supabase-edge-function-auth/pubspec.lock +++ b/demos/supabase-edge-function-auth/pubspec.lock @@ -326,7 +326,7 @@ packages: path: "../../packages/powersync" relative: true source: path - version: "1.3.0" + version: "1.3.1" realtime_client: dependency: transitive description: @@ -448,10 +448,10 @@ packages: dependency: "direct main" description: name: sqlite_async - sha256: "609a8405b8b608ac396dd7f478ed42e230c496eb38fe53dd97e9c592e1cd5cda" + sha256: "139c8f1085132d0941b925efacb4fa0fed9ee40d624739cc26a051dbc36bf727" url: "https://pub.dev" source: hosted - version: "0.6.0" + version: "0.6.1" stack_trace: dependency: transitive description: diff --git a/demos/supabase-simple-chat/pubspec.lock b/demos/supabase-simple-chat/pubspec.lock index 7cc6f802..1e39714a 100644 --- a/demos/supabase-simple-chat/pubspec.lock +++ b/demos/supabase-simple-chat/pubspec.lock @@ -358,7 +358,7 @@ packages: path: "../../packages/powersync" relative: true source: path - version: "1.3.0" + version: "1.3.1" realtime_client: dependency: transitive description: @@ -504,10 +504,10 @@ packages: dependency: transitive description: name: sqlite_async - sha256: "609a8405b8b608ac396dd7f478ed42e230c496eb38fe53dd97e9c592e1cd5cda" + sha256: "139c8f1085132d0941b925efacb4fa0fed9ee40d624739cc26a051dbc36bf727" url: "https://pub.dev" source: hosted - version: "0.6.0" + version: "0.6.1" stack_trace: dependency: transitive description: diff --git a/demos/supabase-todolist/pubspec.lock b/demos/supabase-todolist/pubspec.lock index b17411ef..03ace8fa 100644 --- a/demos/supabase-todolist/pubspec.lock +++ b/demos/supabase-todolist/pubspec.lock @@ -422,7 +422,7 @@ packages: path: "../../packages/powersync" relative: true source: path - version: "1.3.0" + version: "1.3.1" powersync_attachments_helper: dependency: "direct main" description: diff --git a/packages/powersync/CHANGELOG.md b/packages/powersync/CHANGELOG.md index 3e6e89c1..2a36213d 100644 --- a/packages/powersync/CHANGELOG.md +++ b/packages/powersync/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.3.1 + +- Fix "Checksum mismatch" issue when calling `PowerSyncDatabase.connect` multiple times. + ## 1.3.0 - Add `crudThrottleTime` option to arguments when running `PowerSyncDatabase.connect` to set throttle time for crud operations. diff --git a/packages/powersync/pubspec.yaml b/packages/powersync/pubspec.yaml index 820f9d7b..120005c9 100644 --- a/packages/powersync/pubspec.yaml +++ b/packages/powersync/pubspec.yaml @@ -1,5 +1,5 @@ name: powersync -version: 1.3.0 +version: 1.3.1 homepage: https://powersync.com repository: https://github.com/powersync-ja/powersync.dart description: PowerSync Flutter SDK - keep PostgreSQL databases in sync with on-device SQLite databases. From 7e6ab8669aab3e9550097707de54cae4baba2472 Mon Sep 17 00:00:00 2001 From: ScottAtRedHawk Date: Tue, 30 Apr 2024 05:37:51 -0400 Subject: [PATCH 15/39] fix: reset isProcessing when exception is thrown during sync process. (#81) * Reset ability to sync after exception is possibly thrown in syncing_service.dart * Added `catch` statemet syncing_service.dart. * Fix typo. --- .../lib/src/syncing_service.dart | 45 +++++++++++-------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/packages/powersync_attachments_helper/lib/src/syncing_service.dart b/packages/powersync_attachments_helper/lib/src/syncing_service.dart index ec94ff8e..ccb91628 100644 --- a/packages/powersync_attachments_helper/lib/src/syncing_service.dart +++ b/packages/powersync_attachments_helper/lib/src/syncing_service.dart @@ -107,28 +107,35 @@ class SyncingService { /// Handle downloading, uploading or deleting of attachments Future handleSync(Iterable attachments) async { - if (isProcessing == true) { - return; - } - - isProcessing = true; - - for (Attachment attachment in attachments) { - if (AttachmentState.queuedDownload.index == attachment.state) { - log.info('Downloading ${attachment.filename}'); - await downloadAttachment(attachment); - } - if (AttachmentState.queuedUpload.index == attachment.state) { - log.info('Uploading ${attachment.filename}'); - await uploadAttachment(attachment); + if (isProcessing == true) { + return; } - if (AttachmentState.queuedDelete.index == attachment.state) { - log.info('Deleting ${attachment.filename}'); - await deleteAttachment(attachment); + + try { + isProcessing = true; + + for (Attachment attachment in attachments) { + if (AttachmentState.queuedDownload.index == attachment.state) { + log.info('Downloading ${attachment.filename}'); + await downloadAttachment(attachment); + } + if (AttachmentState.queuedUpload.index == attachment.state) { + log.info('Uploading ${attachment.filename}'); + await uploadAttachment(attachment); + } + if (AttachmentState.queuedDelete.index == attachment.state) { + log.info('Deleting ${attachment.filename}'); + await deleteAttachment(attachment); + } } + } catch (error) { + log.severe(error); + rethrow; + } finally { + // if anything throws an exception + // reset the ability to sync again + isProcessing = false; } - - isProcessing = false; } /// Watcher for changes to attachments table From d2d7ee164050acea43aa04bde999c9ceb31ccfec Mon Sep 17 00:00:00 2001 From: Dominic Gunther Bauer <46312751+DominicGBauer@users.noreply.github.com> Date: Tue, 30 Apr 2024 15:04:19 +0200 Subject: [PATCH 16/39] chore(attachments): update version 0.3.2 (#82) * chore(attachments): update version 0.3.2 * fix: lint * docs: update changelog * docs: update changelog --------- Co-authored-by: DominicGBauer --- demos/supabase-todolist/pubspec.lock | 2 +- packages/powersync_attachments_helper/CHANGELOG.md | 4 ++++ .../lib/src/syncing_service.dart | 8 ++++---- packages/powersync_attachments_helper/pubspec.yaml | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/demos/supabase-todolist/pubspec.lock b/demos/supabase-todolist/pubspec.lock index 6781d83b..9946071a 100644 --- a/demos/supabase-todolist/pubspec.lock +++ b/demos/supabase-todolist/pubspec.lock @@ -429,7 +429,7 @@ packages: path: "../../packages/powersync_attachments_helper" relative: true source: path - version: "0.3.1" + version: "0.3.2" realtime_client: dependency: transitive description: diff --git a/packages/powersync_attachments_helper/CHANGELOG.md b/packages/powersync_attachments_helper/CHANGELOG.md index 1028766a..c1f4bde4 100644 --- a/packages/powersync_attachments_helper/CHANGELOG.md +++ b/packages/powersync_attachments_helper/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.3.2 + +- Fix sync not resetting after an error is thrown + ## 0.3.1 - Add periodic syncing and deleting of attachments diff --git a/packages/powersync_attachments_helper/lib/src/syncing_service.dart b/packages/powersync_attachments_helper/lib/src/syncing_service.dart index ccb91628..93c2300c 100644 --- a/packages/powersync_attachments_helper/lib/src/syncing_service.dart +++ b/packages/powersync_attachments_helper/lib/src/syncing_service.dart @@ -107,10 +107,10 @@ class SyncingService { /// Handle downloading, uploading or deleting of attachments Future handleSync(Iterable attachments) async { - if (isProcessing == true) { - return; - } - + if (isProcessing == true) { + return; + } + try { isProcessing = true; diff --git a/packages/powersync_attachments_helper/pubspec.yaml b/packages/powersync_attachments_helper/pubspec.yaml index bb599186..0f00f8cc 100644 --- a/packages/powersync_attachments_helper/pubspec.yaml +++ b/packages/powersync_attachments_helper/pubspec.yaml @@ -1,6 +1,6 @@ name: powersync_attachments_helper description: A helper library for handling attachments when using PowerSync. -version: 0.3.1 +version: 0.3.2 repository: https://github.com/powersync-ja/powersync.dart homepage: https://www.powersync.com/ environment: From a8e977286850e42e1321e91f5f187911712bbdad Mon Sep 17 00:00:00 2001 From: benitav Date: Tue, 30 Apr 2024 19:32:50 +0200 Subject: [PATCH 17/39] Leaner Readme --- packages/powersync/README.md | 158 +++++------------------------------ 1 file changed, 23 insertions(+), 135 deletions(-) diff --git a/packages/powersync/README.md b/packages/powersync/README.md index 611a54a8..04ac65ac 100644 --- a/packages/powersync/README.md +++ b/packages/powersync/README.md @@ -1,151 +1,39 @@ -# PowerSync SDK for Dart/Flutter - -[PowerSync](https://powersync.co) is a service and set of SDKs that keeps PostgreSQL databases in sync with on-device SQLite databases. - -## SDK Features - -* Real-time streaming of changes. -* Direct access to the SQLite database - use SQL on the client and server. -* Operations are asynchronous by default - does not block the UI. -* Supports one write and many reads concurrently. -* No need for client-side database migrations - these are handled automatically. -* Subscribe to queries for live updates. - -## Examples - -For complete app examples, see our [example app gallery](https://docs.powersync.com/resources/demo-apps-example-projects#flutter) - -For examples of some common patterns, see our [example snippets](./example/README.md) - -## Getting started +

+ +

-You'll need to create a PowerSync account and set up a PowerSync instance. You can do this at [https://www.powersync.com/](https://www.powersync.com/). - -### Install the package +# PowerSync SDK for Dart/Flutter -`flutter pub add powersync` +[PowerSync](https://powersync.com) is a service and set of SDKs that keeps Postgres databases in sync with on-device SQLite databases. -### Implement a backend connector and initialize the PowerSync database +This package (`powersync`) is the PowerSync SDK for Dart/Flutter clients. -```dart -import 'package:powersync/powersync.dart'; -import 'package:path_provider/path_provider.dart'; -import 'package:path/path.dart'; +See a summary of features [here](https://docs.powersync.com/client-sdk-references/flutter). -// Define the schema for the local SQLite database. -// You can automatically generate this schema based on your sync rules: -// In the PowerSync dashboard, right-click on your PowerSync instance and then click "Generate client-side schema" -const schema = Schema([ - Table('customers', [Column.text('name'), Column.text('email')]) -]); +# Installation -late PowerSyncDatabase db; +```bash +flutter pub add powersync +``` -// You must implement a backend connector to define how PowerSync communicates with your backend. -class MyBackendConnector extends PowerSyncBackendConnector { - PowerSyncDatabase db; +# Getting Started - MyBackendConnector(this.db); - @override - Future fetchCredentials() async { - // implement fetchCredentials to obtain a JWT from your authentication service - // see https://docs.powersync.com/usage/installation/authentication-setup - } - @override - Future uploadData(PowerSyncDatabase database) async { - // Implement uploadData to send local changes to your backend service - // You can omit this method if you only want to sync data from the server to the client - // see https://docs.powersync.com/usage/installation/upload-data - } -} +Our [full SDK reference](https://docs.powersync.com/client-sdk-references/flutter) contains everything you need to know to get started implementing PowerSync in your project. -openDatabase() async { - final dir = await getApplicationSupportDirectory(); - final path = join(dir.path, 'powersync-dart.db'); +# Changelog - // Setup the database. - db = PowerSyncDatabase(schema: schema, path: path); - await db.initialize(); +A changelog for this SDK is available [here](https://releases.powersync.com/announcements/flutter-client-sdk). - // Connect to backend - db.connect(connector: MyBackendConnector(db)); -} -``` +# API Reference -### Subscribe to changes in data - -```dart -StreamBuilder( - // you can watch any SQL query - stream: return db.watch('SELECT * FROM customers order by id asc'), - builder: (context, snapshot) { - if (snapshot.hasData) { - // TODO: implement your own UI here based on the result set - return ...; - } else { - return const Center(child: CircularProgressIndicator()); - } - }, -) -``` +The full API reference for this SDK can be found [here](https://pub.dev/documentation/powersync/latest/powersync/powersync-library.html). -### Insert, update, and delete data in the SQLite database as you would normally - -```dart -FloatingActionButton( - onPressed: () async { - await db.execute( - 'INSERT INTO customers(id, name, email) VALUES(uuid(), ?, ?)', - ['Fred', 'fred@example.org'], - ); - }, - tooltip: '+', - child: const Icon(Icons.add), -); -``` +# Examples -### Send changes in local data to your backend service - -```dart -// Implement the uploadData method in your backend connector -@override -Future uploadData(PowerSyncDatabase database) async { - final batch = await database.getCrudBatch(); - if (batch == null) return; - for (var op in batch.crud) { - switch (op.op) { - case UpdateType.put: - // Send the data to your backend service - // replace `_myApi` with your own API client or service - await _myApi.put(op.table, op.opData!); - break; - default: - // TODO: implement the other operations (patch, delete) - break; - } - } - await batch.complete(); -} -``` +For example projects built with PowerSync and Flutter, see our [Demo Apps / Example Projects](https://docs.powersync.com/resources/demo-apps-example-projects#flutter) gallery. Most of these projects can also be found in the [`demos/`](../demos/) directory. -### Logging - -You can enable logging to see what's happening under the hood -or to debug connection/authentication/sync issues. - -```dart -Logger.root.level = Level.INFO; -Logger.root.onRecord.listen((record) { - if (kDebugMode) { - print('[${record.loggerName}] ${record.level.name}: ${record.time}: ${record.message}'); - - if (record.error != null) { - print(record.error); - } - if (record.stackTrace != null) { - print(record.stackTrace); - } - } -}); -``` +# Found a bug or need help? +- Join our [Discord server](https://discord.gg/powersync) where you can browse topics from our community, ask questions, share feedback, or just say hello :) +- Please open a [GitHub issue](https://github.com/powersync-ja/powersync.dart/issues) when you come across a bug. +- Have feedback or an idea? [Submit an idea](https://roadmap.powersync.com/tabs/5-roadmap/submit-idea) via our public roadmap or [schedule a chat](https://calendly.com/powersync/powersync-chat) with someone from our product team. From 3be82c6904f52ec2641a32a17a0b90a524af12b4 Mon Sep 17 00:00:00 2001 From: benitav Date: Tue, 30 Apr 2024 19:45:57 +0200 Subject: [PATCH 18/39] Run melos format --- demos/supabase-simple-chat/lib/app_config_template.dart | 1 - demos/supabase-todolist/lib/app_config_template.dart | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/demos/supabase-simple-chat/lib/app_config_template.dart b/demos/supabase-simple-chat/lib/app_config_template.dart index ee964d4f..d7ead31d 100644 --- a/demos/supabase-simple-chat/lib/app_config_template.dart +++ b/demos/supabase-simple-chat/lib/app_config_template.dart @@ -5,4 +5,3 @@ class AppConfig { static const String supabaseAnonKey = 'foo'; static const String powersyncUrl = 'https://foo.powersync.journeyapps.com'; } - diff --git a/demos/supabase-todolist/lib/app_config_template.dart b/demos/supabase-todolist/lib/app_config_template.dart index be2e980e..ccfdfa21 100644 --- a/demos/supabase-todolist/lib/app_config_template.dart +++ b/demos/supabase-todolist/lib/app_config_template.dart @@ -4,5 +4,6 @@ class AppConfig { static const String supabaseUrl = 'https://foo.supabase.co'; static const String supabaseAnonKey = 'foo'; static const String powersyncUrl = 'https://foo.powersync.journeyapps.com'; - static const String supabaseStorageBucket = ''; // Optional. Only required when syncing attachments and using Supabase Storage. See packages/powersync_attachments_helper. + static const String supabaseStorageBucket = + ''; // Optional. Only required when syncing attachments and using Supabase Storage. See packages/powersync_attachments_helper. } From a0e74e6ca861c7418ad2e69ee5707488523788b7 Mon Sep 17 00:00:00 2001 From: Dominic Gunther Bauer <46312751+DominicGBauer@users.noreply.github.com> Date: Thu, 2 May 2024 12:07:37 +0200 Subject: [PATCH 19/39] feat(attachments)!: cater for subdirectories in storage (#78) * feat(attachments): cater for subdirectorires in storage * fix: changelog * chore: make mediaType configurable in example and demo --------- Co-authored-by: DominicGBauer --- .../lib/attachments/photo_capture_widget.dart | 2 +- .../lib/attachments/queue.dart | 17 ++- .../lib/widgets/todo_item_widget.dart | 2 +- demos/supabase-todolist/pubspec.lock | 140 ++++++++---------- .../powersync_attachments_helper/CHANGELOG.md | 5 + .../powersync_attachments_helper/README.md | 16 +- .../example/getting_started.dart | 15 +- .../lib/src/attachments_queue.dart | 22 ++- .../powersync_attachments_helper/pubspec.yaml | 2 +- pubspec.lock | 14 +- 10 files changed, 120 insertions(+), 115 deletions(-) diff --git a/demos/supabase-todolist/lib/attachments/photo_capture_widget.dart b/demos/supabase-todolist/lib/attachments/photo_capture_widget.dart index a4bad5a9..38838dd7 100644 --- a/demos/supabase-todolist/lib/attachments/photo_capture_widget.dart +++ b/demos/supabase-todolist/lib/attachments/photo_capture_widget.dart @@ -58,7 +58,7 @@ class _TakePhotoWidgetState extends State { int photoSize = await photo.length(); TodoItem.addPhoto(photoId, widget.todoId); - attachmentQueue.savePhoto(photoId, photoSize); + attachmentQueue.saveFile(photoId, photoSize); } catch (e) { log.info('Error taking photo: $e'); } diff --git a/demos/supabase-todolist/lib/attachments/queue.dart b/demos/supabase-todolist/lib/attachments/queue.dart index 75273309..2a8dd9ca 100644 --- a/demos/supabase-todolist/lib/attachments/queue.dart +++ b/demos/supabase-todolist/lib/attachments/queue.dart @@ -39,13 +39,15 @@ class PhotoAttachmentQueue extends AbstractAttachmentQueue { } @override - Future savePhoto(String photoId, int size) async { - String filename = '$photoId.jpg'; + Future saveFile(String fileId, int size, + {mediaType = 'image/jpeg'}) async { + String filename = '$fileId.jpg'; + Attachment photoAttachment = Attachment( - id: photoId, + id: fileId, filename: filename, state: AttachmentState.queuedUpload.index, - mediaType: 'image/jpeg', + mediaType: mediaType, localUri: getLocalFilePathSuffix(filename), size: size, ); @@ -54,10 +56,11 @@ class PhotoAttachmentQueue extends AbstractAttachmentQueue { } @override - Future deletePhoto(String photoId) async { - String filename = '$photoId.jpg'; + Future deleteFile(String fileId) async { + String filename = '$fileId.jpg'; + Attachment photoAttachment = Attachment( - id: photoId, + id: fileId, filename: filename, state: AttachmentState.queuedDelete.index); diff --git a/demos/supabase-todolist/lib/widgets/todo_item_widget.dart b/demos/supabase-todolist/lib/widgets/todo_item_widget.dart index efe64fcc..a59812ed 100644 --- a/demos/supabase-todolist/lib/widgets/todo_item_widget.dart +++ b/demos/supabase-todolist/lib/widgets/todo_item_widget.dart @@ -23,7 +23,7 @@ class TodoItemWidget extends StatelessWidget { Future deleteTodo(TodoItem todo) async { if (todo.photoId != null) { - attachmentQueue.deletePhoto(todo.photoId!); + attachmentQueue.deleteFile(todo.photoId!); } await todo.delete(); } diff --git a/demos/supabase-todolist/pubspec.lock b/demos/supabase-todolist/pubspec.lock index 9946071a..2b215540 100644 --- a/demos/supabase-todolist/pubspec.lock +++ b/demos/supabase-todolist/pubspec.lock @@ -5,18 +5,18 @@ packages: dependency: transitive description: name: app_links - sha256: "4e392b5eba997df356ca6021f28431ce1cfeb16758699553a94b13add874a3bb" + sha256: "0fd41f0501f131d931251e0942ac63d6216096a0052aeca037915c2c1deeb121" url: "https://pub.dev" source: hosted - version: "3.5.0" + version: "5.0.0" archive: dependency: transitive description: name: archive - sha256: "22600aa1e926be775fa5fe7e6894e7fb3df9efda8891c73f70fb3262399a432d" + sha256: "0763b45fa9294197a2885c8567927e2830ade852e5c896fd4ab7e0e348d0f373" url: "https://pub.dev" source: hosted - version: "3.4.10" + version: "3.5.0" async: dependency: transitive description: @@ -45,34 +45,34 @@ packages: dependency: transitive description: name: camera_android - sha256: "351429510121d179b9aac5a2e8cb525c3cd6c39f4d709c5f72dfb21726e52371" + sha256: "7b0aba6398afa8475e2bc9115d976efb49cf8db781e922572d443795c04a4f4f" url: "https://pub.dev" source: hosted - version: "0.10.8+16" + version: "0.10.9+1" camera_avfoundation: dependency: transitive description: name: camera_avfoundation - sha256: "7d0763dfcbf060f56aa254a68c103210280bee9e97bbe4fdef23e257a4f70ab9" + sha256: "7d021e8cd30d9b71b8b92b4ad669e80af432d722d18d6aac338572754a786c15" url: "https://pub.dev" source: hosted - version: "0.9.14" + version: "0.9.16" camera_platform_interface: dependency: transitive description: name: camera_platform_interface - sha256: fceb2c36038b6392317b1d5790c6ba9e6ca9f1da3031181b8bea03882bf9387a + sha256: a250314a48ea337b35909a4c9d5416a208d736dcb01d0b02c6af122be66660b0 url: "https://pub.dev" source: hosted - version: "2.7.3" + version: "2.7.4" camera_web: dependency: transitive description: name: camera_web - sha256: f18ccfb33b2a7c49a52ad5aa3f07330b7422faaecbdfd9b9fe8e51182f6ad67d + sha256: "9e9aba2fbab77ce2472924196ff8ac4dd8f9126c4f9a3096171cd1d870d6b26c" url: "https://pub.dev" source: hosted - version: "0.3.2+4" + version: "0.3.3" characters: dependency: transitive description: @@ -97,22 +97,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.18.0" - convert: - dependency: transitive - description: - name: convert - sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592" - url: "https://pub.dev" - source: hosted - version: "3.1.1" cross_file: dependency: transitive description: name: cross_file - sha256: "2f9d2cbccb76127ba28528cb3ae2c2326a122446a83de5a056aaa3880d3882c5" + sha256: "55d7b444feb71301ef6b8838dbc1ae02e63dd48c8773f3810ff53bb1e2945b32" url: "https://pub.dev" source: hosted - version: "0.3.3+7" + version: "0.3.4+1" crypto: dependency: transitive description: @@ -162,18 +154,18 @@ packages: dependency: "direct dev" description: name: flutter_lints - sha256: e2a421b7e59244faef694ba7b30562e489c2b489866e505074eb005cd7060db7 + sha256: "9e8c3858111da373efc5aa341de011d9bd23e2c5c5e0c62bccf32438e192d7b1" url: "https://pub.dev" source: hosted - version: "3.0.1" + version: "3.0.2" flutter_plugin_android_lifecycle: dependency: transitive description: name: flutter_plugin_android_lifecycle - sha256: b068ffc46f82a55844acfa4fdbb61fad72fa2aef0905548419d97f0f95c456da + sha256: "8cf40eebf5dec866a6d1956ad7b4f7016e6c0cc69847ab946833b7d43743809f" url: "https://pub.dev" source: hosted - version: "2.0.17" + version: "2.0.19" flutter_test: dependency: "direct dev" description: flutter @@ -188,18 +180,18 @@ packages: dependency: transitive description: name: functions_client - sha256: "9a0ab83a525c8691a6724746e642de755a299afa04158807787364cd9e718001" + sha256: a70b0dd9a1c35d05d1141557f7e49ffe4de5f450ffde31755a9eeeadca03b8ee url: "https://pub.dev" source: hosted - version: "2.0.0" + version: "2.1.0" gotrue: dependency: transitive description: name: gotrue - sha256: "1bf6354278a98b8a1867263e94921da8a239de07e9babceab2b4e80af651a098" + sha256: c9c984f088320a5c5e87c7a34571e3de3982cca4cbd8b978e59d36baf748edfb url: "https://pub.dev" source: hosted - version: "2.5.1" + version: "2.6.1" gtk: dependency: transitive description: @@ -236,10 +228,10 @@ packages: dependency: transitive description: name: js - sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 + sha256: c1b2e9b5ea78c45e1a0788d29606ba27dc5f71f019f32ca5140f61ef071838cf url: "https://pub.dev" source: hosted - version: "0.6.7" + version: "0.7.1" jwt_decode: dependency: transitive description: @@ -332,18 +324,18 @@ packages: dependency: "direct main" description: name: path_provider - sha256: b27217933eeeba8ff24845c34003b003b2b22151de3c908d0e679e8fe1aa078b + sha256: c9e7d3a4cd1410877472158bee69963a4579f78b68c65a2b7d40d1a7a88bb161 url: "https://pub.dev" source: hosted - version: "2.1.2" + version: "2.1.3" path_provider_android: dependency: transitive description: name: path_provider_android - sha256: "477184d672607c0a3bf68fbbf601805f92ef79c82b64b4d6eb318cbca4c48668" + sha256: a248d8146ee5983446bf03ed5ea8f6533129a12b11f12057ad1b4a67a2b3b41d url: "https://pub.dev" source: hosted - version: "2.2.2" + version: "2.2.4" path_provider_foundation: dependency: transitive description: @@ -400,14 +392,6 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.8" - pointycastle: - dependency: transitive - description: - name: pointycastle - sha256: "43ac87de6e10afabc85c445745a7b799e04de84cebaa4fd7bf55a5e1e9604d29" - url: "https://pub.dev" - source: hosted - version: "3.7.4" postgrest: dependency: transitive description: @@ -429,15 +413,15 @@ packages: path: "../../packages/powersync_attachments_helper" relative: true source: path - version: "0.3.2" + version: "0.4.0" realtime_client: dependency: transitive description: name: realtime_client - sha256: "41d6c5e0327d6c270b98b79bfed672928244af60e2856770f3eff697f9efe459" + sha256: "492a1ab568b3812cb345aad8dd09b3936877edba81a6ab6f5fdf365c155797e1" url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "2.0.4" retry: dependency: transitive description: @@ -458,18 +442,18 @@ packages: dependency: transitive description: name: shared_preferences - sha256: "81429e4481e1ccfb51ede496e916348668fd0921627779233bd24cc3ff6abd02" + sha256: d3bbe5553a986e83980916ded2f0b435ef2e1893dfaa29d5a7a790d0eca12180 url: "https://pub.dev" source: hosted - version: "2.2.2" + version: "2.2.3" shared_preferences_android: dependency: transitive description: name: shared_preferences_android - sha256: "8568a389334b6e83415b6aae55378e158fbc2314e074983362d20c562780fb06" + sha256: "1ee8bf911094a1b592de7ab29add6f826a7331fb854273d55918693d5364a1f2" url: "https://pub.dev" source: hosted - version: "2.2.1" + version: "2.2.2" shared_preferences_foundation: dependency: transitive description: @@ -498,10 +482,10 @@ packages: dependency: transitive description: name: shared_preferences_web - sha256: d762709c2bbe80626ecc819143013cc820fa49ca5e363620ee20a8b15a3e3daf + sha256: "9aee1089b36bd2aafe06582b7d7817fd317ef05fc30e6ba14bff247d0933042a" url: "https://pub.dev" source: hosted - version: "2.2.1" + version: "2.3.0" shared_preferences_windows: dependency: transitive description: @@ -535,18 +519,18 @@ packages: dependency: transitive description: name: sqlite3 - sha256: "072128763f1547e3e9b4735ce846bfd226d68019ccda54db4cd427b12dfdedc9" + sha256: "1abbeb84bf2b1a10e5e1138c913123c8aa9d83cd64e5f9a0dd847b3c83063202" url: "https://pub.dev" source: hosted - version: "2.4.0" + version: "2.4.2" sqlite3_flutter_libs: dependency: transitive description: name: sqlite3_flutter_libs - sha256: d6c31c8511c441d1f12f20b607343df1afe4eddf24a1cf85021677c8eea26060 + sha256: fb2a106a2ea6042fe57de2c47074cc31539a941819c91e105b864744605da3f5 url: "https://pub.dev" source: hosted - version: "0.5.20" + version: "0.5.21" sqlite_async: dependency: "direct main" description: @@ -599,18 +583,18 @@ packages: dependency: transitive description: name: supabase - sha256: f431753d2a4cb9dacd72c7378154f806c2b2cef23859bd9cee1add23821e874d + sha256: ef407187b18c440f4a5c3f3cf30eb5cc1daadd4ff5616febf445a37e0e0ed34e url: "https://pub.dev" source: hosted - version: "2.0.8" + version: "2.1.2" supabase_flutter: dependency: "direct main" description: name: supabase_flutter - sha256: "30e966b89ee61dc9de845e2d7e1c60967b3189c410d105c6d42f09b6259f4cb6" + sha256: "6a77bd6ef6dc451bb2561de0334d68d620b84d7df1de1448dd7962ed5d1a79ea" url: "https://pub.dev" source: hosted - version: "2.3.4" + version: "2.5.2" term_glyph: dependency: transitive description: @@ -639,26 +623,26 @@ packages: dependency: transitive description: name: url_launcher - sha256: c512655380d241a337521703af62d2c122bf7b77a46ff7dd750092aa9433499c + sha256: "6ce1e04375be4eed30548f10a315826fd933c1e493206eab82eed01f438c8d2e" url: "https://pub.dev" source: hosted - version: "6.2.4" + version: "6.2.6" url_launcher_android: dependency: transitive description: name: url_launcher_android - sha256: d4ed0711849dd8e33eb2dd69c25db0d0d3fdc37e0a62e629fe32f57a22db2745 + sha256: "360a6ed2027f18b73c8d98e159dda67a61b7f2e0f6ec26e86c3ada33b0621775" url: "https://pub.dev" source: hosted - version: "6.3.0" + version: "6.3.1" url_launcher_ios: dependency: transitive description: name: url_launcher_ios - sha256: "75bb6fe3f60070407704282a2d295630cab232991eb52542b18347a8a941df03" + sha256: "9149d493b075ed740901f3ee844a38a00b33116c7c5c10d7fb27df8987fb51d5" url: "https://pub.dev" source: hosted - version: "6.2.4" + version: "6.2.5" url_launcher_linux: dependency: transitive description: @@ -687,10 +671,10 @@ packages: dependency: transitive description: name: url_launcher_web - sha256: "7fd2f55fe86cea2897b963e864dc01a7eb0719ecc65fcef4c1cc3d686d718bb2" + sha256: "8d9e750d8c9338601e709cd0885f95825086bd8b642547f26bda435aade95d8a" url: "https://pub.dev" source: hosted - version: "2.2.0" + version: "2.3.1" url_launcher_windows: dependency: transitive description: @@ -703,10 +687,10 @@ packages: dependency: transitive description: name: uuid - sha256: cd210a09f7c18cbe5a02511718e0334de6559871052c90a90c0cca46a4aa81c8 + sha256: "814e9e88f21a176ae1359149021870e87f7cddaf633ab678a5d2b0bff7fd1ba8" url: "https://pub.dev" source: hosted - version: "4.3.3" + version: "4.4.0" vector_math: dependency: transitive description: @@ -727,26 +711,26 @@ packages: dependency: transitive description: name: web - sha256: "1d9158c616048c38f712a6646e317a3426da10e884447626167240d45209cbad" + sha256: "97da13628db363c635202ad97068d47c5b8aa555808e7a9411963c533b449b27" url: "https://pub.dev" source: hosted - version: "0.5.0" + version: "0.5.1" web_socket_channel: dependency: transitive description: name: web_socket_channel - sha256: "1d8e795e2a8b3730c41b8a98a2dff2e0fb57ae6f0764a1c46ec5915387d257b2" + sha256: "58c6666b342a38816b2e7e50ed0f1e261959630becd4c879c4f26bfa14aa5a42" url: "https://pub.dev" source: hosted - version: "2.4.4" + version: "2.4.5" win32: dependency: transitive description: name: win32 - sha256: "464f5674532865248444b4c3daca12bd9bf2d7c47f759ce2617986e7229494a8" + sha256: "0eaf06e3446824099858367950a813472af675116bf63f008a4c2a75ae13e9cb" url: "https://pub.dev" source: hosted - version: "5.2.0" + version: "5.5.0" xdg_directories: dependency: transitive description: @@ -773,4 +757,4 @@ packages: version: "2.0.0" sdks: dart: ">=3.3.0 <4.0.0" - flutter: ">=3.16.6" + flutter: ">=3.19.0" diff --git a/packages/powersync_attachments_helper/CHANGELOG.md b/packages/powersync_attachments_helper/CHANGELOG.md index c1f4bde4..e5b69882 100644 --- a/packages/powersync_attachments_helper/CHANGELOG.md +++ b/packages/powersync_attachments_helper/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.4.0 + +- BREAKING CHANGE: Generalize naming so `savePhoto` and `deletePhoto` have been removed in favour of `saveFile` and `deleteFile` +- Added optional subDirectories argument when initializing the queue so that local subDirectories are created to match any subDirectories on the storage provider allowing files to be saved instead of an error being thrown. + ## 0.3.2 - Fix sync not resetting after an error is thrown diff --git a/packages/powersync_attachments_helper/README.md b/packages/powersync_attachments_helper/README.md index 032319f7..a44f8c9d 100644 --- a/packages/powersync_attachments_helper/README.md +++ b/packages/powersync_attachments_helper/README.md @@ -32,13 +32,13 @@ class PhotoAttachmentQueue extends AbstractAttachmentQueue { // This will create an item on the attachment queue to UPLOAD an image // to remote storage @override - Future savePhoto(String photoId, int size) async { - String filename = '$photoId.jpg'; + Future saveFile(String fileId, int size, {mediaType = 'image/jpeg'}) async { + String filename = '$fileId.jpg'; Attachment photoAttachment = Attachment( - id: photoId, + id: fileId, filename: filename, state: AttachmentState.queuedUpload.index, - mediaType: 'image/jpeg', + mediaType: mediaType, localUri: getLocalFilePathSuffix(filename), size: size, ); @@ -46,13 +46,13 @@ class PhotoAttachmentQueue extends AbstractAttachmentQueue { return attachmentsService.saveAttachment(photoAttachment); } - // This will create an item on the attachment queue to DELETE an image + // This will create an item on the attachment queue to DELETE a file // in local and remote storage @override - Future deletePhoto(String photoId) async { - String filename = '$photoId.jpg'; + Future deleteFile(String fileId) async { + String filename = '$fileId.jpg'; Attachment photoAttachment = Attachment( - id: photoId, + id: fileId, filename: filename, state: AttachmentState.queuedDelete.index); diff --git a/packages/powersync_attachments_helper/example/getting_started.dart b/packages/powersync_attachments_helper/example/getting_started.dart index 3f045b01..f5302508 100644 --- a/packages/powersync_attachments_helper/example/getting_started.dart +++ b/packages/powersync_attachments_helper/example/getting_started.dart @@ -18,13 +18,14 @@ class PhotoAttachmentQueue extends AbstractAttachmentQueue { : super(db: db, remoteStorage: remoteStorage); @override - Future savePhoto(String photoId, int size) async { - String filename = '$photoId.jpg'; + Future saveFile(String fileId, int size, + {mediaType = 'image/jpeg'}) async { + String filename = '$fileId.jpg'; Attachment photoAttachment = Attachment( - id: photoId, + id: fileId, filename: filename, state: AttachmentState.queuedUpload.index, - mediaType: 'image/jpeg', + mediaType: mediaType, localUri: getLocalFilePathSuffix(filename), size: size, ); @@ -33,10 +34,10 @@ class PhotoAttachmentQueue extends AbstractAttachmentQueue { } @override - Future deletePhoto(String photoId) async { - String filename = '$photoId.jpg'; + Future deleteFile(String fileId) async { + String filename = '$fileId.jpg'; Attachment photoAttachment = Attachment( - id: photoId, + id: fileId, filename: filename, state: AttachmentState.queuedDelete.index); diff --git a/packages/powersync_attachments_helper/lib/src/attachments_queue.dart b/packages/powersync_attachments_helper/lib/src/attachments_queue.dart index f2f8e742..7ceb8208 100644 --- a/packages/powersync_attachments_helper/lib/src/attachments_queue.dart +++ b/packages/powersync_attachments_helper/lib/src/attachments_queue.dart @@ -37,6 +37,10 @@ abstract class AbstractAttachmentQueue { /// Default is 5 minutes int intervalInMinutes; + /// Provide the subdirectories located on external storage so that they are created + /// when the attachment queue is initialized. + List? subdirectories; + AbstractAttachmentQueue( {required this.db, required this.remoteStorage, @@ -44,7 +48,8 @@ abstract class AbstractAttachmentQueue { this.attachmentsQueueTableName = defaultAttachmentsQueueTableName, this.onDownloadError, this.onUploadError, - this.intervalInMinutes = 5}) { + this.intervalInMinutes = 5, + this.subdirectories}) { attachmentsService = AttachmentsService( db, localStorage, attachmentDirectoryName, attachmentsQueueTableName); syncingService = SyncingService( @@ -56,11 +61,11 @@ abstract class AbstractAttachmentQueue { /// Set the file extension if you are using a different file type StreamSubscription watchIds({String fileExtension = 'jpg'}); - /// Create a function to save photos using the attachment queue - Future savePhoto(String photoId, int size); + /// Create a function to save files using the attachment queue + Future saveFile(String fileId, int size); - /// Create a function to delete photos using the attachment queue - Future deletePhoto(String photoId); + /// Create a function to delete files using the attachment queue + Future deleteFile(String fileId); /// Initialize the attachment queue by /// 1. Creating attachments directory @@ -70,6 +75,13 @@ abstract class AbstractAttachmentQueue { // Ensure the directory where attachments are downloaded, exists await localStorage.makeDir(await getStorageDirectory()); + if (subdirectories != null) { + for (String subdirectory in subdirectories!) { + await localStorage + .makeDir('${await getStorageDirectory()}/$subdirectory'); + } + } + watchIds(); syncingService.watchAttachments(); syncingService.startPeriodicSync(intervalInMinutes); diff --git a/packages/powersync_attachments_helper/pubspec.yaml b/packages/powersync_attachments_helper/pubspec.yaml index 0f00f8cc..3492b627 100644 --- a/packages/powersync_attachments_helper/pubspec.yaml +++ b/packages/powersync_attachments_helper/pubspec.yaml @@ -1,6 +1,6 @@ name: powersync_attachments_helper description: A helper library for handling attachments when using PowerSync. -version: 0.3.2 +version: 0.4.0 repository: https://github.com/powersync-ja/powersync.dart homepage: https://www.powersync.com/ environment: diff --git a/pubspec.lock b/pubspec.lock index 4c2d22b2..8dd75e5a 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -149,10 +149,10 @@ packages: dependency: transitive description: name: http - sha256: "761a297c042deedc1ffbb156d6e2af13886bb305c2a343a4d972504cd67dd938" + sha256: a2bbf9d017fcced29139daa8ed2bba4ece450ab222871df93ca9eec6f80c34ba url: "https://pub.dev" source: hosted - version: "1.2.1" + version: "1.2.0" http_multi_server: dependency: transitive description: @@ -485,18 +485,18 @@ packages: dependency: transitive description: name: web - sha256: "1d9158c616048c38f712a6646e317a3426da10e884447626167240d45209cbad" + sha256: "4188706108906f002b3a293509234588823c8c979dc83304e229ff400c996b05" url: "https://pub.dev" source: hosted - version: "0.5.0" + version: "0.4.2" web_socket_channel: dependency: transitive description: name: web_socket_channel - sha256: "1d8e795e2a8b3730c41b8a98a2dff2e0fb57ae6f0764a1c46ec5915387d257b2" + sha256: "939ab60734a4f8fa95feacb55804fa278de28bdeef38e616dc08e44a84adea23" url: "https://pub.dev" source: hosted - version: "2.4.4" + version: "2.4.3" webkit_inspection_protocol: dependency: transitive description: @@ -522,4 +522,4 @@ packages: source: hosted version: "2.1.1" sdks: - dart: ">=3.3.0 <4.0.0" + dart: ">=3.2.3 <4.0.0" From dffe0001685ae0d50a40afc2585860d6111fc101 Mon Sep 17 00:00:00 2001 From: Ralf Kistner Date: Mon, 6 May 2024 10:43:40 +0200 Subject: [PATCH 20/39] Fix disconnectAndClear not clearing ps_untyped. --- packages/powersync/lib/src/powersync_database.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/powersync/lib/src/powersync_database.dart b/packages/powersync/lib/src/powersync_database.dart index 434d3c22..8d75fe20 100644 --- a/packages/powersync/lib/src/powersync_database.dart +++ b/packages/powersync/lib/src/powersync_database.dart @@ -329,6 +329,7 @@ class PowerSyncDatabase with SqliteQueries implements SqliteConnection { await tx.execute('DELETE FROM ps_oplog'); await tx.execute('DELETE FROM ps_crud'); await tx.execute('DELETE FROM ps_buckets'); + await tx.execute('DELETE FROM ps_untyped'); final tableGlob = clearLocal ? 'ps_data_*' : 'ps_data__*'; final existingTableRows = await tx.getAll( From f52ed554cec734d01b6ba2c93631f80f4eaf0ef0 Mon Sep 17 00:00:00 2001 From: Kobie Botha Date: Tue, 14 May 2024 08:13:59 -0600 Subject: [PATCH 21/39] Lower path_provider dependency version This increases compatibility with other projects. Dependency calls were audited. Signed-off-by: Kobie Botha --- packages/powersync_attachments_helper/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/powersync_attachments_helper/pubspec.yaml b/packages/powersync_attachments_helper/pubspec.yaml index 3492b627..7b08852f 100644 --- a/packages/powersync_attachments_helper/pubspec.yaml +++ b/packages/powersync_attachments_helper/pubspec.yaml @@ -13,7 +13,7 @@ dependencies: powersync: ^1.2.2 logging: ^1.2.0 sqlite_async: ^0.6.1 - path_provider: ^2.1.2 + path_provider: ^2.0.13 dev_dependencies: lints: ^3.0.0 From 35d1ff9e4101b16f30fc80a52a9bf3834dc016e9 Mon Sep 17 00:00:00 2001 From: Dominic Gunther Bauer <46312751+DominicGBauer@users.noreply.github.com> Date: Wed, 15 May 2024 05:25:33 +0200 Subject: [PATCH 22/39] chore(attachments): update version 0.4.1 (#86) * chore(attachments): update version 0.4.1 * chore: add changelog --------- Co-authored-by: DominicGBauer --- demos/supabase-todolist/pubspec.lock | 2 +- packages/powersync_attachments_helper/CHANGELOG.md | 4 ++++ packages/powersync_attachments_helper/pubspec.yaml | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/demos/supabase-todolist/pubspec.lock b/demos/supabase-todolist/pubspec.lock index 2b215540..c7477d9a 100644 --- a/demos/supabase-todolist/pubspec.lock +++ b/demos/supabase-todolist/pubspec.lock @@ -413,7 +413,7 @@ packages: path: "../../packages/powersync_attachments_helper" relative: true source: path - version: "0.4.0" + version: "0.4.1" realtime_client: dependency: transitive description: diff --git a/packages/powersync_attachments_helper/CHANGELOG.md b/packages/powersync_attachments_helper/CHANGELOG.md index e5b69882..934ebfc3 100644 --- a/packages/powersync_attachments_helper/CHANGELOG.md +++ b/packages/powersync_attachments_helper/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.4.1 + +- Reduce version number of `path_provider` to `2.0.13` + ## 0.4.0 - BREAKING CHANGE: Generalize naming so `savePhoto` and `deletePhoto` have been removed in favour of `saveFile` and `deleteFile` diff --git a/packages/powersync_attachments_helper/pubspec.yaml b/packages/powersync_attachments_helper/pubspec.yaml index 7b08852f..76f8c86d 100644 --- a/packages/powersync_attachments_helper/pubspec.yaml +++ b/packages/powersync_attachments_helper/pubspec.yaml @@ -1,6 +1,6 @@ name: powersync_attachments_helper description: A helper library for handling attachments when using PowerSync. -version: 0.4.0 +version: 0.4.1 repository: https://github.com/powersync-ja/powersync.dart homepage: https://www.powersync.com/ environment: From 87e7c4ea5a7674b24021e52ae3b3ad7f0edf6641 Mon Sep 17 00:00:00 2001 From: Steven Ontong Date: Wed, 29 May 2024 08:51:20 +0200 Subject: [PATCH 23/39] fix tests --- packages/powersync/pubspec.yaml | 4 ++-- packages/powersync/test/streaming_sync_test.dart | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/powersync/pubspec.yaml b/packages/powersync/pubspec.yaml index 4649fd0b..ccb90503 100644 --- a/packages/powersync/pubspec.yaml +++ b/packages/powersync/pubspec.yaml @@ -22,12 +22,12 @@ dependencies: js: ^0.6.7 dev_dependencies: - dcli: ^3.3.5 + dcli: ^4.0.0 lints: ^3.0.0 test: ^1.25.0 test_api: ^0.7.0 path_provider: ^2.0.13 - sqlite3: ^2.3.0 + sqlite3: 2.4.2 shelf: ^1.4.1 shelf_router: ^1.1.4 shelf_static: ^1.1.2 diff --git a/packages/powersync/test/streaming_sync_test.dart b/packages/powersync/test/streaming_sync_test.dart index 398899d3..8a395557 100644 --- a/packages/powersync/test/streaming_sync_test.dart +++ b/packages/powersync/test/streaming_sync_test.dart @@ -116,7 +116,7 @@ void main() { return PowerSyncCredentials(endpoint: server.endpoint, token: 'token'); } - final pdb = await setupPowerSync(path: path); + final pdb = await testUtils.setupPowerSync(path: path); pdb.retryDelay = Duration(milliseconds: 5000); var connector = TestConnector(credentialsCallback); pdb.connect(connector: connector); From 7a7c0a3a3a216591d673fc7ea62887a8299f7294 Mon Sep 17 00:00:00 2001 From: Steven Ontong Date: Wed, 29 May 2024 08:51:32 +0200 Subject: [PATCH 24/39] fix tests --- demos/supabase-anonymous-auth/pubspec.lock | 51 +++++++------ .../supabase-edge-function-auth/pubspec.lock | 51 +++++++------ demos/supabase-simple-chat/pubspec.lock | 53 +++++++------- demos/supabase-todolist/pubspec.lock | 71 ++++++++++--------- .../powersync_attachments_helper/pubspec.yaml | 4 +- packages/powersync_web_worker/pubspec.yaml | 5 +- 6 files changed, 128 insertions(+), 107 deletions(-) diff --git a/demos/supabase-anonymous-auth/pubspec.lock b/demos/supabase-anonymous-auth/pubspec.lock index 0e804340..3a7722ae 100644 --- a/demos/supabase-anonymous-auth/pubspec.lock +++ b/demos/supabase-anonymous-auth/pubspec.lock @@ -204,26 +204,26 @@ packages: dependency: transitive description: name: leak_tracker - sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa" + sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a" url: "https://pub.dev" source: hosted - version: "10.0.0" + version: "10.0.4" leak_tracker_flutter_testing: dependency: transitive description: name: leak_tracker_flutter_testing - sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0 + sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8" url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "3.0.3" leak_tracker_testing: dependency: transitive description: name: leak_tracker_testing - sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47 + sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "3.0.1" lints: dependency: transitive description: @@ -260,10 +260,10 @@ packages: dependency: transitive description: name: meta - sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 + sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136" url: "https://pub.dev" source: hosted - version: "1.11.0" + version: "1.12.0" mime: dependency: transitive description: @@ -366,7 +366,7 @@ packages: path: "../../packages/powersync" relative: true source: path - version: "1.3.0-alpha.3" + version: "1.3.0-alpha.4" realtime_client: dependency: transitive description: @@ -469,13 +469,12 @@ packages: source: hosted version: "7.0.0" sqlite3: - dependency: transitive + dependency: "direct overridden" description: - name: sqlite3 - sha256: "1abbeb84bf2b1a10e5e1138c913123c8aa9d83cd64e5f9a0dd847b3c83063202" - url: "https://pub.dev" - source: hosted - version: "2.4.2" + path: "/Users/stevenontong/Documents/platform_code/powersync/dart_deps/sqlite3.dart/sqlite3" + relative: false + source: path + version: "2.4.1-dev" sqlite3_flutter_libs: dependency: transitive description: @@ -484,13 +483,19 @@ packages: url: "https://pub.dev" source: hosted version: "0.5.20" + sqlite3_web: + dependency: "direct overridden" + description: + path: "/Users/stevenontong/Documents/platform_code/powersync/dart_deps/sqlite3.dart/sqlite3_web" + relative: false + source: path + version: "0.1.0" sqlite_async: dependency: "direct main" description: - name: sqlite_async - sha256: cfe14e9b10db9f40f550125f4a8528ad5f891754a4852bf1c1622a4b0192e80c - url: "https://pub.dev" - source: hosted + path: "/Users/stevenontong/Documents/platform_code/powersync/sqlite_async.dart" + relative: false + source: path version: "0.7.0-alpha.3" stack_trace: dependency: transitive @@ -552,10 +557,10 @@ packages: dependency: transitive description: name: test_api - sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" + sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f" url: "https://pub.dev" source: hosted - version: "0.6.1" + version: "0.7.0" typed_data: dependency: transitive description: @@ -656,10 +661,10 @@ packages: dependency: transitive description: name: vm_service - sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957 + sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec" url: "https://pub.dev" source: hosted - version: "13.0.0" + version: "14.2.1" web: dependency: transitive description: diff --git a/demos/supabase-edge-function-auth/pubspec.lock b/demos/supabase-edge-function-auth/pubspec.lock index 0e804340..3a7722ae 100644 --- a/demos/supabase-edge-function-auth/pubspec.lock +++ b/demos/supabase-edge-function-auth/pubspec.lock @@ -204,26 +204,26 @@ packages: dependency: transitive description: name: leak_tracker - sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa" + sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a" url: "https://pub.dev" source: hosted - version: "10.0.0" + version: "10.0.4" leak_tracker_flutter_testing: dependency: transitive description: name: leak_tracker_flutter_testing - sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0 + sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8" url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "3.0.3" leak_tracker_testing: dependency: transitive description: name: leak_tracker_testing - sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47 + sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "3.0.1" lints: dependency: transitive description: @@ -260,10 +260,10 @@ packages: dependency: transitive description: name: meta - sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 + sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136" url: "https://pub.dev" source: hosted - version: "1.11.0" + version: "1.12.0" mime: dependency: transitive description: @@ -366,7 +366,7 @@ packages: path: "../../packages/powersync" relative: true source: path - version: "1.3.0-alpha.3" + version: "1.3.0-alpha.4" realtime_client: dependency: transitive description: @@ -469,13 +469,12 @@ packages: source: hosted version: "7.0.0" sqlite3: - dependency: transitive + dependency: "direct overridden" description: - name: sqlite3 - sha256: "1abbeb84bf2b1a10e5e1138c913123c8aa9d83cd64e5f9a0dd847b3c83063202" - url: "https://pub.dev" - source: hosted - version: "2.4.2" + path: "/Users/stevenontong/Documents/platform_code/powersync/dart_deps/sqlite3.dart/sqlite3" + relative: false + source: path + version: "2.4.1-dev" sqlite3_flutter_libs: dependency: transitive description: @@ -484,13 +483,19 @@ packages: url: "https://pub.dev" source: hosted version: "0.5.20" + sqlite3_web: + dependency: "direct overridden" + description: + path: "/Users/stevenontong/Documents/platform_code/powersync/dart_deps/sqlite3.dart/sqlite3_web" + relative: false + source: path + version: "0.1.0" sqlite_async: dependency: "direct main" description: - name: sqlite_async - sha256: cfe14e9b10db9f40f550125f4a8528ad5f891754a4852bf1c1622a4b0192e80c - url: "https://pub.dev" - source: hosted + path: "/Users/stevenontong/Documents/platform_code/powersync/sqlite_async.dart" + relative: false + source: path version: "0.7.0-alpha.3" stack_trace: dependency: transitive @@ -552,10 +557,10 @@ packages: dependency: transitive description: name: test_api - sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" + sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f" url: "https://pub.dev" source: hosted - version: "0.6.1" + version: "0.7.0" typed_data: dependency: transitive description: @@ -656,10 +661,10 @@ packages: dependency: transitive description: name: vm_service - sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957 + sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec" url: "https://pub.dev" source: hosted - version: "13.0.0" + version: "14.2.1" web: dependency: transitive description: diff --git a/demos/supabase-simple-chat/pubspec.lock b/demos/supabase-simple-chat/pubspec.lock index 1166ab2d..6a47c703 100644 --- a/demos/supabase-simple-chat/pubspec.lock +++ b/demos/supabase-simple-chat/pubspec.lock @@ -236,26 +236,26 @@ packages: dependency: transitive description: name: leak_tracker - sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa" + sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a" url: "https://pub.dev" source: hosted - version: "10.0.0" + version: "10.0.4" leak_tracker_flutter_testing: dependency: transitive description: name: leak_tracker_flutter_testing - sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0 + sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8" url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "3.0.3" leak_tracker_testing: dependency: transitive description: name: leak_tracker_testing - sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47 + sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "3.0.1" lints: dependency: transitive description: @@ -292,10 +292,10 @@ packages: dependency: transitive description: name: meta - sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 + sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136" url: "https://pub.dev" source: hosted - version: "1.11.0" + version: "1.12.0" mime: dependency: transitive description: @@ -398,7 +398,7 @@ packages: path: "../../packages/powersync" relative: true source: path - version: "1.3.0-alpha.3" + version: "1.3.0-alpha.4" realtime_client: dependency: transitive description: @@ -525,13 +525,12 @@ packages: source: hosted version: "7.0.0" sqlite3: - dependency: transitive + dependency: "direct overridden" description: - name: sqlite3 - sha256: "1abbeb84bf2b1a10e5e1138c913123c8aa9d83cd64e5f9a0dd847b3c83063202" - url: "https://pub.dev" - source: hosted - version: "2.4.2" + path: "/Users/stevenontong/Documents/platform_code/powersync/dart_deps/sqlite3.dart/sqlite3" + relative: false + source: path + version: "2.4.1-dev" sqlite3_flutter_libs: dependency: transitive description: @@ -540,13 +539,19 @@ packages: url: "https://pub.dev" source: hosted version: "0.5.20" + sqlite3_web: + dependency: "direct overridden" + description: + path: "/Users/stevenontong/Documents/platform_code/powersync/dart_deps/sqlite3.dart/sqlite3_web" + relative: false + source: path + version: "0.1.0" sqlite_async: - dependency: transitive + dependency: "direct overridden" description: - name: sqlite_async - sha256: cfe14e9b10db9f40f550125f4a8528ad5f891754a4852bf1c1622a4b0192e80c - url: "https://pub.dev" - source: hosted + path: "/Users/stevenontong/Documents/platform_code/powersync/sqlite_async.dart" + relative: false + source: path version: "0.7.0-alpha.3" stack_trace: dependency: transitive @@ -608,10 +613,10 @@ packages: dependency: transitive description: name: test_api - sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" + sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f" url: "https://pub.dev" source: hosted - version: "0.6.1" + version: "0.7.0" timeago: dependency: "direct main" description: @@ -720,10 +725,10 @@ packages: dependency: transitive description: name: vm_service - sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957 + sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec" url: "https://pub.dev" source: hosted - version: "13.0.0" + version: "14.2.1" web: dependency: transitive description: diff --git a/demos/supabase-todolist/pubspec.lock b/demos/supabase-todolist/pubspec.lock index 8df39958..dcd8f3e8 100644 --- a/demos/supabase-todolist/pubspec.lock +++ b/demos/supabase-todolist/pubspec.lock @@ -97,6 +97,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.18.0" + convert: + dependency: transitive + description: + name: convert + sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592" + url: "https://pub.dev" + source: hosted + version: "3.1.1" cross_file: dependency: transitive description: @@ -252,10 +260,10 @@ packages: dependency: transitive description: name: js - sha256: c1b2e9b5ea78c45e1a0788d29606ba27dc5f71f019f32ca5140f61ef071838cf + sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 url: "https://pub.dev" source: hosted - version: "0.7.1" + version: "0.6.7" jwt_decode: dependency: transitive description: @@ -268,26 +276,26 @@ packages: dependency: transitive description: name: leak_tracker - sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa" + sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a" url: "https://pub.dev" source: hosted - version: "10.0.0" + version: "10.0.4" leak_tracker_flutter_testing: dependency: transitive description: name: leak_tracker_flutter_testing - sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0 + sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8" url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "3.0.3" leak_tracker_testing: dependency: transitive description: name: leak_tracker_testing - sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47 + sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "3.0.1" lints: dependency: transitive description: @@ -324,10 +332,10 @@ packages: dependency: transitive description: name: meta - sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 + sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136" url: "https://pub.dev" source: hosted - version: "1.11.0" + version: "1.12.0" mime: dependency: transitive description: @@ -424,14 +432,6 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.8" - pointycastle: - dependency: transitive - description: - name: pointycastle - sha256: "70fe966348fe08c34bf929582f1d8247d9d9408130723206472b4687227e4333" - url: "https://pub.dev" - source: hosted - version: "3.8.0" postgrest: dependency: transitive description: @@ -446,7 +446,7 @@ packages: path: "../../packages/powersync" relative: true source: path - version: "1.3.0-alpha.3" + version: "1.3.0-alpha.4" powersync_attachments_helper: dependency: "direct main" description: @@ -556,13 +556,12 @@ packages: source: hosted version: "7.0.0" sqlite3: - dependency: transitive + dependency: "direct overridden" description: - name: sqlite3 - sha256: "1abbeb84bf2b1a10e5e1138c913123c8aa9d83cd64e5f9a0dd847b3c83063202" - url: "https://pub.dev" - source: hosted - version: "2.4.2" + path: "/Users/stevenontong/Documents/platform_code/powersync/dart_deps/sqlite3.dart/sqlite3" + relative: false + source: path + version: "2.4.1-dev" sqlite3_flutter_libs: dependency: transitive description: @@ -571,13 +570,19 @@ packages: url: "https://pub.dev" source: hosted version: "0.5.21" + sqlite3_web: + dependency: "direct overridden" + description: + path: "/Users/stevenontong/Documents/platform_code/powersync/dart_deps/sqlite3.dart/sqlite3_web" + relative: false + source: path + version: "0.1.0" sqlite_async: dependency: "direct main" description: - name: sqlite_async - sha256: cfe14e9b10db9f40f550125f4a8528ad5f891754a4852bf1c1622a4b0192e80c - url: "https://pub.dev" - source: hosted + path: "/Users/stevenontong/Documents/platform_code/powersync/sqlite_async.dart" + relative: false + source: path version: "0.7.0-alpha.3" stack_trace: dependency: transitive @@ -647,10 +652,10 @@ packages: dependency: transitive description: name: test_api - sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" + sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f" url: "https://pub.dev" source: hosted - version: "0.6.1" + version: "0.7.0" typed_data: dependency: transitive description: @@ -751,10 +756,10 @@ packages: dependency: transitive description: name: vm_service - sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957 + sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec" url: "https://pub.dev" source: hosted - version: "13.0.0" + version: "14.2.1" web: dependency: transitive description: diff --git a/packages/powersync_attachments_helper/pubspec.yaml b/packages/powersync_attachments_helper/pubspec.yaml index 45f598a0..ba3d0631 100644 --- a/packages/powersync_attachments_helper/pubspec.yaml +++ b/packages/powersync_attachments_helper/pubspec.yaml @@ -12,8 +12,8 @@ dependencies: powersync: ^1.3.0-alpha.3 logging: ^1.2.0 - sqlite3: ^2.3.0 - sqlite_async: ^0.7.0-alpha.2 + sqlite3: 2.4.2 + sqlite_async: ^0.7.0-alpha.3 path_provider: ^2.0.13 dev_dependencies: diff --git a/packages/powersync_web_worker/pubspec.yaml b/packages/powersync_web_worker/pubspec.yaml index 977c489e..9b366a7d 100644 --- a/packages/powersync_web_worker/pubspec.yaml +++ b/packages/powersync_web_worker/pubspec.yaml @@ -12,11 +12,12 @@ executables: compile_worker: bin/compile_worker.dart dev_dependencies: - dcli: ^3.3.5 + dcli: ^4.0.1 uuid: ^4.2.0 async: ^2.10.0 path: ^1.8.3 - sqlite3: ^2.3.0 + # Note that 2.4.3 fails to compile the web worker + sqlite3: 2.4.2 drift: git: url: https://github.com/powersync-ja/drift.git From 8d00dd6430c2dbaf8642dbe952ee31d6ecd563d1 Mon Sep 17 00:00:00 2001 From: Steven Ontong Date: Wed, 29 May 2024 09:08:50 +0200 Subject: [PATCH 25/39] revert test package version --- packages/powersync/pubspec.yaml | 2 +- packages/powersync_attachments_helper/pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/powersync/pubspec.yaml b/packages/powersync/pubspec.yaml index ccb90503..cc6fdb55 100644 --- a/packages/powersync/pubspec.yaml +++ b/packages/powersync/pubspec.yaml @@ -27,7 +27,7 @@ dev_dependencies: test: ^1.25.0 test_api: ^0.7.0 path_provider: ^2.0.13 - sqlite3: 2.4.2 + sqlite3: ^2.3.0 shelf: ^1.4.1 shelf_router: ^1.1.4 shelf_static: ^1.1.2 diff --git a/packages/powersync_attachments_helper/pubspec.yaml b/packages/powersync_attachments_helper/pubspec.yaml index ba3d0631..4ce568a2 100644 --- a/packages/powersync_attachments_helper/pubspec.yaml +++ b/packages/powersync_attachments_helper/pubspec.yaml @@ -12,7 +12,7 @@ dependencies: powersync: ^1.3.0-alpha.3 logging: ^1.2.0 - sqlite3: 2.4.2 + sqlite3: ^2.3.0 sqlite_async: ^0.7.0-alpha.3 path_provider: ^2.0.13 From decbdcb5410859d5b0f3ae43e5f763669aad1fe8 Mon Sep 17 00:00:00 2001 From: Steven Ontong Date: Wed, 29 May 2024 09:19:18 +0200 Subject: [PATCH 26/39] Revert "revert test package version" This reverts commit 8d00dd6430c2dbaf8642dbe952ee31d6ecd563d1. --- packages/powersync/pubspec.yaml | 2 +- packages/powersync_attachments_helper/pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/powersync/pubspec.yaml b/packages/powersync/pubspec.yaml index cc6fdb55..ccb90503 100644 --- a/packages/powersync/pubspec.yaml +++ b/packages/powersync/pubspec.yaml @@ -27,7 +27,7 @@ dev_dependencies: test: ^1.25.0 test_api: ^0.7.0 path_provider: ^2.0.13 - sqlite3: ^2.3.0 + sqlite3: 2.4.2 shelf: ^1.4.1 shelf_router: ^1.1.4 shelf_static: ^1.1.2 diff --git a/packages/powersync_attachments_helper/pubspec.yaml b/packages/powersync_attachments_helper/pubspec.yaml index 4ce568a2..ba3d0631 100644 --- a/packages/powersync_attachments_helper/pubspec.yaml +++ b/packages/powersync_attachments_helper/pubspec.yaml @@ -12,7 +12,7 @@ dependencies: powersync: ^1.3.0-alpha.3 logging: ^1.2.0 - sqlite3: ^2.3.0 + sqlite3: 2.4.2 sqlite_async: ^0.7.0-alpha.3 path_provider: ^2.0.13 From ea99fb3afbab6d4d056b67a107d03432cc6e05e5 Mon Sep 17 00:00:00 2001 From: Steven Ontong Date: Wed, 29 May 2024 09:20:34 +0200 Subject: [PATCH 27/39] fix tests --- .../lib/src/database/native/native_powersync_database.dart | 7 +++---- .../powersync/lib/src/database/powersync_db_mixin.dart | 1 + 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/powersync/lib/src/database/native/native_powersync_database.dart b/packages/powersync/lib/src/database/native/native_powersync_database.dart index 52618154..d9ed775e 100644 --- a/packages/powersync/lib/src/database/native/native_powersync_database.dart +++ b/packages/powersync/lib/src/database/native/native_powersync_database.dart @@ -134,8 +134,7 @@ class PowerSyncDatabaseImpl // Disconnect if connected await disconnect(); - final _disconnecter = AbortController(); - disconnecter = _disconnecter; + disconnecter = AbortController(); await isInitialized; final dbref = database.isolateConnectionFactory(); @@ -162,7 +161,7 @@ class PowerSyncDatabaseImpl updateSubscription = throttled.listen((event) { port.send(['update']); }); - _disconnecter.onAbort.then((_) { + disconnecter?.onAbort.then((_) { port.send(['close']); }).ignore(); } else if (action == 'uploadCrud') { @@ -215,7 +214,7 @@ class PowerSyncDatabaseImpl disconnected(); }); - if (_disconnecter?.aborted == true) { + if (disconnecter?.aborted == true) { disconnected(); return; } diff --git a/packages/powersync/lib/src/database/powersync_db_mixin.dart b/packages/powersync/lib/src/database/powersync_db_mixin.dart index 78499e5e..b76e0ee4 100644 --- a/packages/powersync/lib/src/database/powersync_db_mixin.dart +++ b/packages/powersync/lib/src/database/powersync_db_mixin.dart @@ -136,6 +136,7 @@ mixin PowerSyncDatabaseMixin implements SqliteConnection { /// Abstract connection method to be implemented by platform specific /// classes. This is wrapped inside an exclusive mutex in the [connect] /// method. + @protected Future baseConnect( {required PowerSyncBackendConnector connector, From 02b96a62851fbad92a87ebfe95a91cebf7f128dd Mon Sep 17 00:00:00 2001 From: Steven Ontong Date: Wed, 29 May 2024 09:27:33 +0200 Subject: [PATCH 28/39] update reconnect test --- .../lib/src/database/native/native_powersync_database.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/powersync/lib/src/database/native/native_powersync_database.dart b/packages/powersync/lib/src/database/native/native_powersync_database.dart index d9ed775e..0049923b 100644 --- a/packages/powersync/lib/src/database/native/native_powersync_database.dart +++ b/packages/powersync/lib/src/database/native/native_powersync_database.dart @@ -197,7 +197,7 @@ class PowerSyncDatabaseImpl logger.severe('Sync Isolate error', message); // Reconnect - connect(connector: connector); + baseConnect(connector: connector); }); disconnected() { From 7c0ae774880ec319f8ced0cfa3ae423d0420593c Mon Sep 17 00:00:00 2001 From: Steven Ontong Date: Thu, 30 May 2024 10:48:01 +0200 Subject: [PATCH 29/39] fix issues where Sync stream manager's mutex would not release --- .../native/native_powersync_database.dart | 22 ++++++++++++------- .../powersync_database_impl_stub.dart | 2 ++ .../lib/src/database/powersync_db_mixin.dart | 1 + .../database/web/web_powersync_database.dart | 1 + 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/packages/powersync/lib/src/database/native/native_powersync_database.dart b/packages/powersync/lib/src/database/native/native_powersync_database.dart index 0049923b..c5d8cb08 100644 --- a/packages/powersync/lib/src/database/native/native_powersync_database.dart +++ b/packages/powersync/lib/src/database/native/native_powersync_database.dart @@ -118,6 +118,7 @@ class PowerSyncDatabaseImpl } @override + @internal /// Connect to the PowerSync service, and keep the databases in sync. /// @@ -134,10 +135,11 @@ class PowerSyncDatabaseImpl // Disconnect if connected await disconnect(); - disconnecter = AbortController(); + final disconnector = AbortController(); + disconnecter = disconnector; await isInitialized; - final dbref = database.isolateConnectionFactory(); + final dbRef = database.isolateConnectionFactory(); ReceivePort rPort = ReceivePort(); StreamSubscription? updateSubscription; rPort.listen((data) async { @@ -161,7 +163,7 @@ class PowerSyncDatabaseImpl updateSubscription = throttled.listen((event) { port.send(['update']); }); - disconnecter?.onAbort.then((_) { + disconnector.onAbort.then((_) { port.send(['close']); }).ignore(); } else if (action == 'uploadCrud') { @@ -197,11 +199,11 @@ class PowerSyncDatabaseImpl logger.severe('Sync Isolate error', message); // Reconnect - baseConnect(connector: connector); + connect(connector: connector, crudThrottleTime: crudThrottleTime); }); disconnected() { - disconnecter?.completeAbort(); + disconnector.completeAbort(); disconnecter = null; rPort.close(); // Clear status apart from lastSyncedAt @@ -220,7 +222,7 @@ class PowerSyncDatabaseImpl } Isolate.spawn(_powerSyncDatabaseIsolate, - _PowerSyncDatabaseIsolateArgs(rPort.sendPort, dbref, retryDelay), + _PowerSyncDatabaseIsolateArgs(rPort.sendPort, dbRef, retryDelay), debugName: 'PowerSyncDatabase', onError: errorPort.sendPort, onExit: exitPort.sendPort); @@ -274,12 +276,17 @@ Future _powerSyncDatabaseIsolate( final upstreamDbClient = args.dbRef.upstreamPort.open(); CommonDatabase? db; - rPort.listen((message) { + final Mutex mutex = args.dbRef.mutex.open(); + rPort.listen((message) async { if (message is List) { String action = message[0]; if (action == 'update') { updateController.add('update'); } else if (action == 'close') { + // The SyncSqliteConnection uses this mutex + // It needs to be closed before killing the isolate + // in order to free the mutex for other operations. + await mutex.close(); db?.dispose(); updateController.close(); upstreamDbClient.close(); @@ -318,7 +325,6 @@ Future _powerSyncDatabaseIsolate( } runZonedGuarded(() async { - final mutex = args.dbRef.mutex.open(); db = await args.dbRef.openFactory .open(SqliteOpenOptions(primaryConnection: false, readOnly: false)); final connection = SyncSqliteConnection(db!, mutex); diff --git a/packages/powersync/lib/src/database/powersync_database_impl_stub.dart b/packages/powersync/lib/src/database/powersync_database_impl_stub.dart index d2cf637f..b41ec948 100644 --- a/packages/powersync/lib/src/database/powersync_database_impl_stub.dart +++ b/packages/powersync/lib/src/database/powersync_database_impl_stub.dart @@ -1,6 +1,7 @@ import 'dart:async'; import 'package:logging/logging.dart'; +import 'package:meta/meta.dart'; import 'package:powersync/sqlite_async.dart'; import 'package:powersync/src/database/powersync_db_mixin.dart'; import 'package:powersync/src/open_factory/abstract_powersync_open_factory.dart'; @@ -109,6 +110,7 @@ class PowerSyncDatabaseImpl Logger get logger => throw UnimplementedError(); @override + @internal Future baseConnect( {required PowerSyncBackendConnector connector, Duration crudThrottleTime = const Duration(milliseconds: 10)}) { diff --git a/packages/powersync/lib/src/database/powersync_db_mixin.dart b/packages/powersync/lib/src/database/powersync_db_mixin.dart index b76e0ee4..8ed77a49 100644 --- a/packages/powersync/lib/src/database/powersync_db_mixin.dart +++ b/packages/powersync/lib/src/database/powersync_db_mixin.dart @@ -137,6 +137,7 @@ mixin PowerSyncDatabaseMixin implements SqliteConnection { /// classes. This is wrapped inside an exclusive mutex in the [connect] /// method. @protected + @internal Future baseConnect( {required PowerSyncBackendConnector connector, diff --git a/packages/powersync/lib/src/database/web/web_powersync_database.dart b/packages/powersync/lib/src/database/web/web_powersync_database.dart index a25d60da..fef67ba0 100644 --- a/packages/powersync/lib/src/database/web/web_powersync_database.dart +++ b/packages/powersync/lib/src/database/web/web_powersync_database.dart @@ -113,6 +113,7 @@ class PowerSyncDatabaseImpl } @override + @internal /// Connect to the PowerSync service, and keep the databases in sync. /// From 51198a587d34af585eb82ed2c6310f1ed602f908 Mon Sep 17 00:00:00 2001 From: benitav Date: Thu, 30 May 2024 11:09:26 +0200 Subject: [PATCH 30/39] Update graphic --- packages/powersync/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/powersync/README.md b/packages/powersync/README.md index 04ac65ac..f2935aa1 100644 --- a/packages/powersync/README.md +++ b/packages/powersync/README.md @@ -1,5 +1,5 @@

- +

# PowerSync SDK for Dart/Flutter From 87216d752fbee26284a9dec78f82251a5f0716fb Mon Sep 17 00:00:00 2001 From: benitav Date: Thu, 30 May 2024 11:09:41 +0200 Subject: [PATCH 31/39] Remove old graphic --- demos/supabase-todolist/README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/demos/supabase-todolist/README.md b/demos/supabase-todolist/README.md index 3471f779..da957598 100644 --- a/demos/supabase-todolist/README.md +++ b/demos/supabase-todolist/README.md @@ -1,8 +1,6 @@ # PowerSync + Supabase Flutter Demo: Todo List App -![docs-supabase-integration](https://github.com/journeyapps/powersync-supabase-flutter-demo/assets/277659/291fa2eb-abe6-4567-8d4b-c88e0ee850cf) - -Demo app demonstrating use of the PowerSync SDK for Flutter together with Supabase. For a step-by-step guide, see [here](https://docs.powersync.co/integration-guides/supabase). +Demo app demonstrating use of the PowerSync SDK for Flutter together with Supabase. For a step-by-step guide, see [here](https://docs.powersync.com/integration-guides/supabase). # Running the app From b6e5abdee459b8804a779f0fb551478b113336d9 Mon Sep 17 00:00:00 2001 From: benitav Date: Thu, 30 May 2024 11:26:23 +0200 Subject: [PATCH 32/39] Update banner image in repo root --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5a961254..64f47e72 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@

- +

*Bad connectivity is everywhere, and we're tired of it. PowerSync is on a mission to help developers write offline-first real-time reactive apps.* From a8bfafb196c04d5d689937dff841a1842ad518c1 Mon Sep 17 00:00:00 2001 From: Steven Ontong Date: Thu, 30 May 2024 11:33:39 +0200 Subject: [PATCH 33/39] update dependencies --- demos/supabase-anonymous-auth/pubspec.lock | 25 +++++------ demos/supabase-anonymous-auth/pubspec.yaml | 2 +- .../supabase-edge-function-auth/pubspec.lock | 25 +++++------ demos/supabase-simple-chat/pubspec.lock | 27 +++++------- demos/supabase-todolist/pubspec.lock | 25 +++++------ demos/supabase-todolist/pubspec.yaml | 2 +- pubspec.lock | 41 ------------------- pubspec.yaml | 6 --- 8 files changed, 43 insertions(+), 110 deletions(-) diff --git a/demos/supabase-anonymous-auth/pubspec.lock b/demos/supabase-anonymous-auth/pubspec.lock index 3a7722ae..c077e7ac 100644 --- a/demos/supabase-anonymous-auth/pubspec.lock +++ b/demos/supabase-anonymous-auth/pubspec.lock @@ -469,12 +469,13 @@ packages: source: hosted version: "7.0.0" sqlite3: - dependency: "direct overridden" + dependency: transitive description: - path: "/Users/stevenontong/Documents/platform_code/powersync/dart_deps/sqlite3.dart/sqlite3" - relative: false - source: path - version: "2.4.1-dev" + name: sqlite3 + sha256: b384f598b813b347c5a7e5ffad82cbaff1bec3d1561af267041e66f6f0899295 + url: "https://pub.dev" + source: hosted + version: "2.4.3" sqlite3_flutter_libs: dependency: transitive description: @@ -483,19 +484,13 @@ packages: url: "https://pub.dev" source: hosted version: "0.5.20" - sqlite3_web: - dependency: "direct overridden" - description: - path: "/Users/stevenontong/Documents/platform_code/powersync/dart_deps/sqlite3.dart/sqlite3_web" - relative: false - source: path - version: "0.1.0" sqlite_async: dependency: "direct main" description: - path: "/Users/stevenontong/Documents/platform_code/powersync/sqlite_async.dart" - relative: false - source: path + name: sqlite_async + sha256: cfe14e9b10db9f40f550125f4a8528ad5f891754a4852bf1c1622a4b0192e80c + url: "https://pub.dev" + source: hosted version: "0.7.0-alpha.3" stack_trace: dependency: transitive diff --git a/demos/supabase-anonymous-auth/pubspec.yaml b/demos/supabase-anonymous-auth/pubspec.yaml index 571d190b..b3ef363b 100644 --- a/demos/supabase-anonymous-auth/pubspec.yaml +++ b/demos/supabase-anonymous-auth/pubspec.yaml @@ -16,7 +16,7 @@ dependencies: supabase_flutter: ^2.0.2 path: ^1.8.3 logging: ^1.2.0 - sqlite_async: ^0.7.0-alpha.2 + sqlite_async: ^0.7.0-alpha.3 universal_io: ^2.2.2 dev_dependencies: diff --git a/demos/supabase-edge-function-auth/pubspec.lock b/demos/supabase-edge-function-auth/pubspec.lock index 3a7722ae..c077e7ac 100644 --- a/demos/supabase-edge-function-auth/pubspec.lock +++ b/demos/supabase-edge-function-auth/pubspec.lock @@ -469,12 +469,13 @@ packages: source: hosted version: "7.0.0" sqlite3: - dependency: "direct overridden" + dependency: transitive description: - path: "/Users/stevenontong/Documents/platform_code/powersync/dart_deps/sqlite3.dart/sqlite3" - relative: false - source: path - version: "2.4.1-dev" + name: sqlite3 + sha256: b384f598b813b347c5a7e5ffad82cbaff1bec3d1561af267041e66f6f0899295 + url: "https://pub.dev" + source: hosted + version: "2.4.3" sqlite3_flutter_libs: dependency: transitive description: @@ -483,19 +484,13 @@ packages: url: "https://pub.dev" source: hosted version: "0.5.20" - sqlite3_web: - dependency: "direct overridden" - description: - path: "/Users/stevenontong/Documents/platform_code/powersync/dart_deps/sqlite3.dart/sqlite3_web" - relative: false - source: path - version: "0.1.0" sqlite_async: dependency: "direct main" description: - path: "/Users/stevenontong/Documents/platform_code/powersync/sqlite_async.dart" - relative: false - source: path + name: sqlite_async + sha256: cfe14e9b10db9f40f550125f4a8528ad5f891754a4852bf1c1622a4b0192e80c + url: "https://pub.dev" + source: hosted version: "0.7.0-alpha.3" stack_trace: dependency: transitive diff --git a/demos/supabase-simple-chat/pubspec.lock b/demos/supabase-simple-chat/pubspec.lock index 6a47c703..7cb6ad3e 100644 --- a/demos/supabase-simple-chat/pubspec.lock +++ b/demos/supabase-simple-chat/pubspec.lock @@ -525,12 +525,13 @@ packages: source: hosted version: "7.0.0" sqlite3: - dependency: "direct overridden" + dependency: transitive description: - path: "/Users/stevenontong/Documents/platform_code/powersync/dart_deps/sqlite3.dart/sqlite3" - relative: false - source: path - version: "2.4.1-dev" + name: sqlite3 + sha256: b384f598b813b347c5a7e5ffad82cbaff1bec3d1561af267041e66f6f0899295 + url: "https://pub.dev" + source: hosted + version: "2.4.3" sqlite3_flutter_libs: dependency: transitive description: @@ -539,19 +540,13 @@ packages: url: "https://pub.dev" source: hosted version: "0.5.20" - sqlite3_web: - dependency: "direct overridden" - description: - path: "/Users/stevenontong/Documents/platform_code/powersync/dart_deps/sqlite3.dart/sqlite3_web" - relative: false - source: path - version: "0.1.0" sqlite_async: - dependency: "direct overridden" + dependency: transitive description: - path: "/Users/stevenontong/Documents/platform_code/powersync/sqlite_async.dart" - relative: false - source: path + name: sqlite_async + sha256: cfe14e9b10db9f40f550125f4a8528ad5f891754a4852bf1c1622a4b0192e80c + url: "https://pub.dev" + source: hosted version: "0.7.0-alpha.3" stack_trace: dependency: transitive diff --git a/demos/supabase-todolist/pubspec.lock b/demos/supabase-todolist/pubspec.lock index dcd8f3e8..6746d3a4 100644 --- a/demos/supabase-todolist/pubspec.lock +++ b/demos/supabase-todolist/pubspec.lock @@ -556,12 +556,13 @@ packages: source: hosted version: "7.0.0" sqlite3: - dependency: "direct overridden" + dependency: transitive description: - path: "/Users/stevenontong/Documents/platform_code/powersync/dart_deps/sqlite3.dart/sqlite3" - relative: false - source: path - version: "2.4.1-dev" + name: sqlite3 + sha256: "1abbeb84bf2b1a10e5e1138c913123c8aa9d83cd64e5f9a0dd847b3c83063202" + url: "https://pub.dev" + source: hosted + version: "2.4.2" sqlite3_flutter_libs: dependency: transitive description: @@ -570,19 +571,13 @@ packages: url: "https://pub.dev" source: hosted version: "0.5.21" - sqlite3_web: - dependency: "direct overridden" - description: - path: "/Users/stevenontong/Documents/platform_code/powersync/dart_deps/sqlite3.dart/sqlite3_web" - relative: false - source: path - version: "0.1.0" sqlite_async: dependency: "direct main" description: - path: "/Users/stevenontong/Documents/platform_code/powersync/sqlite_async.dart" - relative: false - source: path + name: sqlite_async + sha256: cfe14e9b10db9f40f550125f4a8528ad5f891754a4852bf1c1622a4b0192e80c + url: "https://pub.dev" + source: hosted version: "0.7.0-alpha.3" stack_trace: dependency: transitive diff --git a/demos/supabase-todolist/pubspec.yaml b/demos/supabase-todolist/pubspec.yaml index 07e0d3a4..b6a160dd 100644 --- a/demos/supabase-todolist/pubspec.yaml +++ b/demos/supabase-todolist/pubspec.yaml @@ -17,7 +17,7 @@ dependencies: supabase_flutter: ^2.0.1 path: ^1.8.3 logging: ^1.2.0 - sqlite_async: ^0.7.0-alpha.2 + sqlite_async: ^0.7.0-alpha.3 camera: ^0.10.5+7 image: ^4.1.3 universal_io: ^2.2.2 diff --git a/pubspec.lock b/pubspec.lock index 99f242bf..556d7257 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -113,22 +113,6 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.3" - drift: - dependency: transitive - description: - name: drift - sha256: b50a8342c6ddf05be53bda1d246404cbad101b64dc73e8d6d1ac1090d119b4e2 - url: "https://pub.dev" - source: hosted - version: "2.15.0" - ffi: - dependency: transitive - description: - name: ffi - sha256: "7bf0adc28a23d395f19f3f1eb21dd7cfd1dd9f8e1c50051c069122e6853bc878" - url: "https://pub.dev" - source: hosted - version: "2.1.0" file: dependency: transitive description: @@ -265,14 +249,6 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.0" - mutex: - dependency: transitive - description: - name: mutex - sha256: "8827da25de792088eb33e572115a5eb0d61d61a3c01acbc8bcbe76ed78f1a1f2" - url: "https://pub.dev" - source: hosted - version: "3.1.0" node_preamble: dependency: transitive description: @@ -417,23 +393,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.10.0" - sqlite3: - dependency: transitive - description: - name: sqlite3 - sha256: c4a4c5a4b2a32e2d0f6837b33d7c91a67903891a5b7dbe706cf4b1f6b0c798c5 - url: "https://pub.dev" - source: hosted - version: "2.3.0" - sqlite_async: - dependency: "direct overridden" - description: - path: "." - ref: web - resolved-ref: f946e1ad70d61ae0eee930c59e567e8a01f1ca77 - url: "https://github.com/powersync-ja/sqlite_async.dart.git" - source: git - version: "0.6.0" stack_trace: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 20fa5f20..6d2b07ac 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -8,12 +8,6 @@ environment: # Add regular dependencies here. -dependency_overrides: - sqlite_async: - git: - url: https://github.com/powersync-ja/sqlite_async.dart.git - ref: web # branch name - dev_dependencies: lints: ^2.1.1 melos: ^3.4.0 From 6b8ed50ed69277c823c4bc1800623437d5db7346 Mon Sep 17 00:00:00 2001 From: Steven Ontong Date: Thu, 30 May 2024 11:39:58 +0200 Subject: [PATCH 34/39] cleanup --- packages/powersync_attachments_helper/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/powersync_attachments_helper/CHANGELOG.md b/packages/powersync_attachments_helper/CHANGELOG.md index 0da659df..982ae07e 100644 --- a/packages/powersync_attachments_helper/CHANGELOG.md +++ b/packages/powersync_attachments_helper/CHANGELOG.md @@ -24,7 +24,7 @@ ## 0.3.0-alpha.1 -- Added initial support for Web platform.s +- Added initial support for Web platforms ## 0.2.1 From ec49cb5979d46171d2cd9bb69ce5473c76290b24 Mon Sep 17 00:00:00 2001 From: Steven Ontong Date: Thu, 30 May 2024 11:54:27 +0200 Subject: [PATCH 35/39] update dependencies --- packages/powersync/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/powersync/pubspec.yaml b/packages/powersync/pubspec.yaml index ccb90503..cc6fdb55 100644 --- a/packages/powersync/pubspec.yaml +++ b/packages/powersync/pubspec.yaml @@ -27,7 +27,7 @@ dev_dependencies: test: ^1.25.0 test_api: ^0.7.0 path_provider: ^2.0.13 - sqlite3: 2.4.2 + sqlite3: ^2.3.0 shelf: ^1.4.1 shelf_router: ^1.1.4 shelf_static: ^1.1.2 From 7347e9a1b6897b2a94ebda7d26b8f66979b3bf1c Mon Sep 17 00:00:00 2001 From: Steven Ontong Date: Thu, 30 May 2024 11:55:11 +0200 Subject: [PATCH 36/39] update sqlite versions --- packages/powersync_attachments_helper/pubspec.yaml | 2 +- packages/powersync_web_worker/pubspec.yaml | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/powersync_attachments_helper/pubspec.yaml b/packages/powersync_attachments_helper/pubspec.yaml index ba3d0631..4ce568a2 100644 --- a/packages/powersync_attachments_helper/pubspec.yaml +++ b/packages/powersync_attachments_helper/pubspec.yaml @@ -12,7 +12,7 @@ dependencies: powersync: ^1.3.0-alpha.3 logging: ^1.2.0 - sqlite3: 2.4.2 + sqlite3: ^2.3.0 sqlite_async: ^0.7.0-alpha.3 path_provider: ^2.0.13 diff --git a/packages/powersync_web_worker/pubspec.yaml b/packages/powersync_web_worker/pubspec.yaml index 9b366a7d..058171f9 100644 --- a/packages/powersync_web_worker/pubspec.yaml +++ b/packages/powersync_web_worker/pubspec.yaml @@ -16,8 +16,7 @@ dev_dependencies: uuid: ^4.2.0 async: ^2.10.0 path: ^1.8.3 - # Note that 2.4.3 fails to compile the web worker - sqlite3: 2.4.2 + sqlite3: ^2.3.0 drift: git: url: https://github.com/powersync-ja/drift.git From a5c929ff852eeacb6d15bc712efa2338c066404e Mon Sep 17 00:00:00 2001 From: Steven Ontong Date: Thu, 30 May 2024 12:11:22 +0200 Subject: [PATCH 37/39] update lockfiles after testing --- demos/supabase-todolist/ios/Podfile.lock | 22 +++++++++---------- demos/supabase-todolist/macos/Podfile.lock | 22 +++++++++---------- .../macos/Runner.xcodeproj/project.pbxproj | 2 +- .../xcshareddata/xcschemes/Runner.xcscheme | 2 +- packages/powersync/pubspec.yaml | 1 - packages/powersync_web_worker/pubspec.yaml | 5 +++-- 6 files changed, 27 insertions(+), 27 deletions(-) diff --git a/demos/supabase-todolist/ios/Podfile.lock b/demos/supabase-todolist/ios/Podfile.lock index 56f60723..6f1f5d82 100644 --- a/demos/supabase-todolist/ios/Podfile.lock +++ b/demos/supabase-todolist/ios/Podfile.lock @@ -10,18 +10,18 @@ PODS: - shared_preferences_foundation (0.0.1): - Flutter - FlutterMacOS - - sqlite3 (3.45.1): - - sqlite3/common (= 3.45.1) - - sqlite3/common (3.45.1) - - sqlite3/fts5 (3.45.1): + - "sqlite3 (3.45.3+1)": + - "sqlite3/common (= 3.45.3+1)" + - "sqlite3/common (3.45.3+1)" + - "sqlite3/fts5 (3.45.3+1)": - sqlite3/common - - sqlite3/perf-threadsafe (3.45.1): + - "sqlite3/perf-threadsafe (3.45.3+1)": - sqlite3/common - - sqlite3/rtree (3.45.1): + - "sqlite3/rtree (3.45.3+1)": - sqlite3/common - sqlite3_flutter_libs (0.0.1): - Flutter - - sqlite3 (~> 3.45.1) + - "sqlite3 (~> 3.45.3+1)" - sqlite3/fts5 - sqlite3/perf-threadsafe - sqlite3/rtree @@ -58,14 +58,14 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/url_launcher_ios/ios" SPEC CHECKSUMS: - app_links: 5ef33d0d295a89d9d16bb81b0e3b0d5f70d6c875 + app_links: e70ca16b4b0f88253b3b3660200d4a10b4ea9795 camera_avfoundation: 759172d1a77ae7be0de08fc104cfb79738b8a59e Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c shared_preferences_foundation: b4c3b4cddf1c21f02770737f147a3f5da9d39695 - sqlite3: 73b7fc691fdc43277614250e04d183740cb15078 - sqlite3_flutter_libs: af0e8fe9bce48abddd1ffdbbf839db0302d72d80 - url_launcher_ios: bbd758c6e7f9fd7b5b1d4cde34d2b95fcce5e812 + sqlite3: 02d1f07eaaa01f80a1c16b4b31dfcbb3345ee01a + sqlite3_flutter_libs: 9bfe005308998aeca155330bbc2ea6dddf834a3b + url_launcher_ios: 6116280ddcfe98ab8820085d8d76ae7449447586 PODFILE CHECKSUM: f7b3cb7384a2d5da4b22b090e1f632de7f377987 diff --git a/demos/supabase-todolist/macos/Podfile.lock b/demos/supabase-todolist/macos/Podfile.lock index f3ca846a..a7d30ad6 100644 --- a/demos/supabase-todolist/macos/Podfile.lock +++ b/demos/supabase-todolist/macos/Podfile.lock @@ -8,18 +8,18 @@ PODS: - shared_preferences_foundation (0.0.1): - Flutter - FlutterMacOS - - sqlite3 (3.45.1): - - sqlite3/common (= 3.45.1) - - sqlite3/common (3.45.1) - - sqlite3/fts5 (3.45.1): + - "sqlite3 (3.45.3+1)": + - "sqlite3/common (= 3.45.3+1)" + - "sqlite3/common (3.45.3+1)" + - "sqlite3/fts5 (3.45.3+1)": - sqlite3/common - - sqlite3/perf-threadsafe (3.45.1): + - "sqlite3/perf-threadsafe (3.45.3+1)": - sqlite3/common - - sqlite3/rtree (3.45.1): + - "sqlite3/rtree (3.45.3+1)": - sqlite3/common - sqlite3_flutter_libs (0.0.1): - FlutterMacOS - - sqlite3 (~> 3.45.1) + - "sqlite3 (~> 3.45.3+1)" - sqlite3/fts5 - sqlite3/perf-threadsafe - sqlite3/rtree @@ -53,14 +53,14 @@ EXTERNAL SOURCES: :path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos SPEC CHECKSUMS: - app_links: 4481ed4d71f384b0c3ae5016f4633aa73d32ff67 + app_links: 10e0a0ab602ffaf34d142cd4862f29d34b303b2a FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24 path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c shared_preferences_foundation: b4c3b4cddf1c21f02770737f147a3f5da9d39695 - sqlite3: 73b7fc691fdc43277614250e04d183740cb15078 - sqlite3_flutter_libs: 06a05802529659a272beac4ee1350bfec294f386 + sqlite3: 02d1f07eaaa01f80a1c16b4b31dfcbb3345ee01a + sqlite3_flutter_libs: 8d204ef443cf0d5c1c8b058044eab53f3943a9c5 url_launcher_macos: d2691c7dd33ed713bf3544850a623080ec693d95 PODFILE CHECKSUM: 236401fc2c932af29a9fcf0e97baeeb2d750d367 -COCOAPODS: 1.13.0 +COCOAPODS: 1.15.2 diff --git a/demos/supabase-todolist/macos/Runner.xcodeproj/project.pbxproj b/demos/supabase-todolist/macos/Runner.xcodeproj/project.pbxproj index 46a2dce9..fe47ba76 100644 --- a/demos/supabase-todolist/macos/Runner.xcodeproj/project.pbxproj +++ b/demos/supabase-todolist/macos/Runner.xcodeproj/project.pbxproj @@ -259,7 +259,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 1430; - LastUpgradeCheck = 1430; + LastUpgradeCheck = 1510; ORGANIZATIONNAME = ""; TargetAttributes = { 33CC10EC2044A3C60003C045 = { diff --git a/demos/supabase-todolist/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/demos/supabase-todolist/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index cc0e03af..2c526589 100644 --- a/demos/supabase-todolist/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/demos/supabase-todolist/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ Date: Thu, 30 May 2024 12:22:14 +0200 Subject: [PATCH 38/39] better version ranges --- packages/powersync/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/powersync/pubspec.yaml b/packages/powersync/pubspec.yaml index 29353525..cacd337e 100644 --- a/packages/powersync/pubspec.yaml +++ b/packages/powersync/pubspec.yaml @@ -26,7 +26,7 @@ dev_dependencies: test: ^1.25.0 test_api: ^0.7.0 path_provider: ^2.0.13 - sqlite3: ^2.3.0 + sqlite3: '>2.3.0 <2.4.3' shelf: ^1.4.1 shelf_router: ^1.1.4 shelf_static: ^1.1.2 From d3ddb126116b532889892ef927744fb3551f54e2 Mon Sep 17 00:00:00 2001 From: Steven Ontong Date: Thu, 30 May 2024 12:29:10 +0200 Subject: [PATCH 39/39] restore dcli --- packages/powersync/pubspec.yaml | 1 + packages/powersync_attachments_helper/pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/powersync/pubspec.yaml b/packages/powersync/pubspec.yaml index cacd337e..35e56799 100644 --- a/packages/powersync/pubspec.yaml +++ b/packages/powersync/pubspec.yaml @@ -22,6 +22,7 @@ dependencies: js: ^0.6.7 dev_dependencies: + dcli: ^4.0.0 lints: ^3.0.0 test: ^1.25.0 test_api: ^0.7.0 diff --git a/packages/powersync_attachments_helper/pubspec.yaml b/packages/powersync_attachments_helper/pubspec.yaml index 4ce568a2..9a1d4644 100644 --- a/packages/powersync_attachments_helper/pubspec.yaml +++ b/packages/powersync_attachments_helper/pubspec.yaml @@ -12,7 +12,7 @@ dependencies: powersync: ^1.3.0-alpha.3 logging: ^1.2.0 - sqlite3: ^2.3.0 + sqlite3: '>2.3.0 <2.4.3' sqlite_async: ^0.7.0-alpha.3 path_provider: ^2.0.13