diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b35088..6feb8ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## [1.3.0] - 2023-12-12 + +* Added class `SyncStateInfo` describing the current synchronization state and errors. +* Add `state` getter. + ## [1.2.1] - 2023-03-01 * Add `debugDoNotSendChanges()` method. diff --git a/lib/in_sync_interface.dart b/lib/in_sync_interface.dart index a7d9197..6dbbd8c 100644 --- a/lib/in_sync_interface.dart +++ b/lib/in_sync_interface.dart @@ -1,3 +1,4 @@ library in_sync_interface; export 'src/sync_repository.dart'; +export 'src/sync_state_info.dart'; diff --git a/lib/src/sync_repository.dart b/lib/src/sync_repository.dart index 16608e4..1708f72 100644 --- a/lib/src/sync_repository.dart +++ b/lib/src/sync_repository.dart @@ -1,3 +1,5 @@ +import 'package:in_sync_interface/src/sync_state_info.dart'; + /// The reposotory for work with synchronization. /// /// By default the synchronization is off (see. [isEnabled]), @@ -56,4 +58,7 @@ abstract class SyncRepository { /// Used to release the memory allocated to variables when the repository is no longer in use. Future dispose(); + + /// Returns the synchronization job status stream. + Stream get state; } diff --git a/lib/src/sync_state_info.dart b/lib/src/sync_state_info.dart new file mode 100644 index 0000000..5996681 --- /dev/null +++ b/lib/src/sync_state_info.dart @@ -0,0 +1,111 @@ +/// Synchronization status information, including errors. +class SyncStateInfo { + final SyncState state; + final SyncError? syncError; + + const SyncStateInfo( + this.state, { + this.syncError, + }); + + /// Fatal error. + bool get isFatalError => + syncError == SyncError.authIncorrectCriticalVersion || + syncError == SyncError.syncIncorrectData || + syncError == SyncError.syncFieldNotFound || + syncError == SyncError.syncEmptyFile; + + /// Temporary error. + bool get isTemporaryError => + syncError == SyncError.syncBlocked || + syncError == SyncError.syncTemporarilyImpossible || + syncError == SyncError.networkError || + syncError == SyncError.syncInternalSyncError || + syncError == SyncError.temporaryServerError; +} + +/// Synchronization error name. +enum SyncError { + /// Unsupported client version. + authIncorrectCriticalVersion, + + /// The transmitted data is incorrect. + syncIncorrectData, + + /// Synchronization is blocked. + /// + /// Another client is synchronizing. + syncBlocked, + + /// Error while saving data. + /// + /// Internal error when saving on the server. + syncNotSaved, + + /// The entity could not be found. + /// + /// The creation event was not processed on the server + /// this entity, so it can't update. + syncEntityNotFound, + + /// Could not find the field. + /// + /// An entity field update was sent that the server does not know about. + syncFieldNotFound, + + /// An empty file was transferred. + /// + /// An attempt was made to load a file of zero size. + syncEmptyFile, + + /// Internal synchronization error on the server. + syncInternalSyncError, + + /// Synchronization is temporarily unavailable. + syncTemporarilyImpossible, + + /// Error updating entities. + updateEntityError, + + /// Error downloading files. + downloadFilesError, + + /// Network error. + networkError, + + /// Authorisation error. + authError, + + /// Temporary server error. + temporaryServerError, + + /// Internal error. + internalError, + + /// Error updating links. + updateLinksExeption, + + /// Unknown error. + unknown, +} + +/// Sync status. +enum SyncState { + /// Initialization. + initializing, + + /// Synchronization was completed successfully. + ok, + + /// The last synchronization attempt failed with an error. + failed, + + /// Synchronization is disabled. + disabled, + + /// Synchronization in progress. + pending, + + /// Waiting for first synchronization. + waiting, +} diff --git a/pubspec.lock b/pubspec.lock index 2da5932..7b9c985 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -5,337 +5,385 @@ packages: dependency: transitive description: name: _fe_analyzer_shared - url: "https://pub.dartlang.org" + sha256: d994c55943e77955bd2cd299c6c02c52ceffc3d21a26461f903f7e10abc05b82 + url: "https://pub.dev" source: hosted version: "34.0.0" analyzer: dependency: transitive description: name: analyzer - url: "https://pub.dartlang.org" + sha256: "426436ca1a3390b330aedf78dad8d70d8df3dc88cf4cabd870428fb02b00119e" + url: "https://pub.dev" source: hosted version: "3.2.0" args: dependency: transitive description: name: args - url: "https://pub.dartlang.org" + sha256: "0bd9a99b6eb96f07af141f0eb53eace8983e8e5aa5de59777aca31684680ef22" + url: "https://pub.dev" source: hosted version: "2.3.0" async: dependency: transitive description: name: async - url: "https://pub.dartlang.org" + sha256: db4766341bd8ecb66556f31ab891a5d596ef829221993531bd64a8e6342f0cda + url: "https://pub.dev" source: hosted version: "2.8.2" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.dartlang.org" + sha256: "5bbf32bc9e518d41ec49718e2931cd4527292c9b0c6d2dffcf7fe6b9a8a8cf72" + url: "https://pub.dev" source: hosted version: "2.1.0" charcode: dependency: transitive description: name: charcode - url: "https://pub.dartlang.org" + sha256: fb98c0f6d12c920a02ee2d998da788bca066ca5f148492b7085ee23372b12306 + url: "https://pub.dev" source: hosted version: "1.3.1" cli_util: dependency: transitive description: name: cli_util - url: "https://pub.dartlang.org" + sha256: "66f86e916d285c1a93d3b79587d94bd71984a66aac4ff74e524cfa7877f1395c" + url: "https://pub.dev" source: hosted version: "0.3.5" collection: dependency: transitive description: name: collection - url: "https://pub.dartlang.org" + sha256: "6d4193120997ecfd09acf0e313f13dc122b119e5eca87ef57a7d065ec9183762" + url: "https://pub.dev" source: hosted version: "1.15.0" convert: dependency: transitive description: name: convert - url: "https://pub.dartlang.org" + sha256: f08428ad63615f96a27e34221c65e1a451439b5f26030f78d790f461c686d65d + url: "https://pub.dev" source: hosted version: "3.0.1" coverage: dependency: transitive description: name: coverage - url: "https://pub.dartlang.org" + sha256: c0122af6b3548369d6b7830c7a140d85c9a988d8d29c4976aa9ce4de46b122ef + url: "https://pub.dev" source: hosted version: "1.1.0" crypto: dependency: transitive description: name: crypto - url: "https://pub.dartlang.org" + sha256: cf75650c66c0316274e21d7c43d3dea246273af5955bd94e8184837cd577575c + url: "https://pub.dev" source: hosted version: "3.0.1" file: dependency: transitive description: name: file - url: "https://pub.dartlang.org" + sha256: b69516f2c26a5bcac4eee2e32512e1a5205ab312b3536c1c1227b2b942b5f9ad + url: "https://pub.dev" source: hosted version: "6.1.2" frontend_server_client: dependency: transitive description: name: frontend_server_client - url: "https://pub.dartlang.org" + sha256: "6d2930621b9377f6a4b7d260fce525d48dd77a334f0d5d4177d07b0dcb76c032" + url: "https://pub.dev" source: hosted version: "2.1.2" glob: dependency: transitive description: name: glob - url: "https://pub.dartlang.org" + sha256: "8321dd2c0ab0683a91a51307fa844c6db4aa8e3981219b78961672aaab434658" + url: "https://pub.dev" source: hosted version: "2.0.2" http_multi_server: dependency: transitive description: name: http_multi_server - url: "https://pub.dartlang.org" + sha256: bfb651625e251a88804ad6d596af01ea903544757906addcb2dcdf088b5ea185 + url: "https://pub.dev" source: hosted version: "3.0.1" http_parser: dependency: transitive description: name: http_parser - url: "https://pub.dartlang.org" + sha256: e362d639ba3bc07d5a71faebb98cde68c05bfbcfbbb444b60b6f60bb67719185 + url: "https://pub.dev" source: hosted version: "4.0.0" innim_lint: dependency: "direct dev" description: name: innim_lint - url: "https://pub.dartlang.org" + sha256: "7634a41723431aece5e9d1dd5547a5f643f2abb7d6c6837c53608d3c74c271c0" + url: "https://pub.dev" source: hosted version: "0.3.1" io: dependency: transitive description: name: io - url: "https://pub.dartlang.org" + sha256: "0d4c73c3653ab85bf696d51a9657604c900a370549196a91f33e4c39af760852" + url: "https://pub.dev" source: hosted version: "1.0.3" js: dependency: transitive description: name: js - url: "https://pub.dartlang.org" + sha256: d9bdfd70d828eeb352390f81b18d6a354ef2044aa28ef25682079797fa7cd174 + url: "https://pub.dev" source: hosted version: "0.6.3" logging: dependency: transitive description: name: logging - url: "https://pub.dartlang.org" + sha256: "293ae2d49fd79d4c04944c3a26dfd313382d5f52e821ec57119230ae16031ad4" + url: "https://pub.dev" source: hosted version: "1.0.2" matcher: dependency: transitive description: name: matcher - url: "https://pub.dartlang.org" + sha256: "2e2c34e631f93410daa3ee3410250eadc77ac6befc02a040eda8a123f34e6f5a" + url: "https://pub.dev" source: hosted version: "0.12.11" meta: dependency: transitive description: name: meta - url: "https://pub.dartlang.org" + sha256: "5202fdd37b4da5fd14a237ed0a01cad6c1efd4c99b5b5a0d3c9237f3728c9485" + url: "https://pub.dev" source: hosted version: "1.7.0" mime: dependency: transitive description: name: mime - url: "https://pub.dartlang.org" + sha256: fd5f81041e6a9fc9b9d7fa2cb8a01123f9f5d5d49136e06cb9dc7d33689529f4 + url: "https://pub.dev" source: hosted version: "1.0.1" node_preamble: dependency: transitive description: name: node_preamble - url: "https://pub.dartlang.org" + sha256: "8ebdbaa3b96d5285d068f80772390d27c21e1fa10fb2df6627b1b9415043608d" + url: "https://pub.dev" source: hosted version: "2.0.1" package_config: dependency: transitive description: name: package_config - url: "https://pub.dartlang.org" + sha256: a4d5ede5ca9c3d88a2fef1147a078570c861714c806485c596b109819135bc12 + url: "https://pub.dev" source: hosted version: "2.0.2" path: dependency: transitive description: name: path - url: "https://pub.dartlang.org" + sha256: "240ed0e9bd73daa2182e33c4efc68c7dd53c7c656f3da73515a2d163e151412d" + url: "https://pub.dev" source: hosted version: "1.8.1" pool: dependency: transitive description: name: pool - url: "https://pub.dartlang.org" + sha256: "05955e3de2683e1746222efd14b775df7131139e07695dc8e24650f6b4204504" + url: "https://pub.dev" source: hosted version: "1.5.0" pub_semver: dependency: transitive description: name: pub_semver - url: "https://pub.dartlang.org" + sha256: b5a5fcc6425ea43704852ba4453ba94b08c2226c63418a260240c3a054579014 + url: "https://pub.dev" source: hosted version: "2.1.0" shelf: dependency: transitive description: name: shelf - url: "https://pub.dartlang.org" + sha256: c240984c924796e055e831a0a36db23be8cb04f170b26df572931ab36418421d + url: "https://pub.dev" source: hosted version: "1.2.0" shelf_packages_handler: dependency: transitive description: name: shelf_packages_handler - url: "https://pub.dartlang.org" + sha256: e0b44ebddec91e70a713e13adf93c1b2100821303b86a18e1ef1d082bd8bd9b8 + url: "https://pub.dev" source: hosted version: "3.0.0" shelf_static: dependency: transitive description: name: shelf_static - url: "https://pub.dartlang.org" + sha256: "4a0d12cd512aa4fc55fed5f6280f02ef183f47ba29b4b0dfd621b1c99b7e6361" + url: "https://pub.dev" source: hosted version: "1.1.0" shelf_web_socket: dependency: transitive description: name: shelf_web_socket - url: "https://pub.dartlang.org" + sha256: fd84910bf7d58db109082edf7326b75322b8f186162028482f53dc892f00332d + url: "https://pub.dev" source: hosted version: "1.0.1" source_map_stack_trace: dependency: transitive description: name: source_map_stack_trace - url: "https://pub.dartlang.org" + sha256: "8c463326277f68a628abab20580047b419c2ff66756fd0affd451f73f9508c11" + url: "https://pub.dev" source: hosted version: "2.1.0" source_maps: dependency: transitive description: name: source_maps - url: "https://pub.dartlang.org" + sha256: "52de2200bb098de739794c82d09c41ac27b2e42fd7e23cce7b9c74bf653c7296" + url: "https://pub.dev" source: hosted version: "0.10.10" source_span: dependency: transitive description: name: source_span - url: "https://pub.dartlang.org" + sha256: d77dbb9d0b7469d91e42d352334b2b4bbd5cec4379542f1bdb630db368c4d9f6 + url: "https://pub.dev" source: hosted version: "1.8.2" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.dartlang.org" + sha256: f8d9f247e2f9f90e32d1495ff32dac7e4ae34ffa7194c5ff8fcc0fd0e52df774 + url: "https://pub.dev" source: hosted version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.dartlang.org" + sha256: db47e4797198ee601990820437179bb90219f918962318d494ada2b4b11e6f6d + url: "https://pub.dev" source: hosted version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.dartlang.org" + sha256: dd11571b8a03f7cadcf91ec26a77e02bfbd6bbba2a512924d3116646b4198fc4 + url: "https://pub.dev" source: hosted version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.dartlang.org" + sha256: a88162591b02c1f3a3db3af8ce1ea2b374bd75a7bb8d5e353bcfbdc79d719830 + url: "https://pub.dev" source: hosted version: "1.2.0" test: dependency: "direct dev" description: name: test - url: "https://pub.dartlang.org" + sha256: fd53f3bac5c70f26eec065456f73b20b11ea969aaa1099928bf9a6c1fd0e1403 + url: "https://pub.dev" source: hosted version: "1.20.1" test_api: dependency: transitive description: name: test_api - url: "https://pub.dartlang.org" + sha256: d8ca35bbbeef2d037e5693a3c8a381505afebfbfee7bc33fff5581bc4e16a939 + url: "https://pub.dev" source: hosted version: "0.4.9" test_core: dependency: transitive description: name: test_core - url: "https://pub.dartlang.org" + sha256: cc8bc45cbe52e8133293537ac4cffc4d9b35c93e91481eb64ef2304e2e722949 + url: "https://pub.dev" source: hosted version: "0.4.11" typed_data: dependency: transitive description: name: typed_data - url: "https://pub.dartlang.org" + sha256: "53bdf7e979cfbf3e28987552fd72f637e63f3c8724c9e56d9246942dc2fa36ee" + url: "https://pub.dev" source: hosted version: "1.3.0" vm_service: dependency: transitive description: name: vm_service - url: "https://pub.dartlang.org" + sha256: b5b99b53cb72c6e7461f86cf3201477bd4daca99ca8a636ffa0be7b967718909 + url: "https://pub.dev" source: hosted version: "8.1.0" watcher: dependency: transitive description: name: watcher - url: "https://pub.dartlang.org" + sha256: e42dfcc48f67618344da967b10f62de57e04bae01d9d3af4c2596f3712a88c99 + url: "https://pub.dev" source: hosted version: "1.0.1" web_socket_channel: dependency: transitive description: name: web_socket_channel - url: "https://pub.dartlang.org" + sha256: "0c2ada1b1aeb2ad031ca81872add6be049b8cb479262c6ad3c4b0f9c24eaab2f" + url: "https://pub.dev" source: hosted version: "2.1.0" webkit_inspection_protocol: dependency: transitive description: name: webkit_inspection_protocol - url: "https://pub.dartlang.org" + sha256: "5adb6ab8ed14e22bb907aae7338f0c206ea21e7a27004e97664b16c120306f00" + url: "https://pub.dev" source: hosted version: "1.0.0" yaml: dependency: transitive description: name: yaml - url: "https://pub.dartlang.org" + sha256: "3cee79b1715110341012d27756d9bae38e650588acd38d3f3c610822e1337ace" + url: "https://pub.dev" source: hosted version: "3.1.0" sdks: - dart: ">=2.14.0 <3.0.0" + dart: ">=2.14.0 <4.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index 3942bf8..08356a6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: in_sync_interface description: An interface for synchronization functional. Used by in_sync. -version: 1.2.1 +version: 1.3.0 homepage: https://github.com/innim/ repository: https://github.com/Innim/in_sync_interface issue_tracker: https://github.com/Innim/in_sync_interface/issues