synq_manager 2.1.10
synq_manager: ^2.1.10 copied to clipboard
Offline-first data synchronization engine with intelligent conflict resolution and real-time events.
Changelog #
2.1.10 #
Added #
- ๐ Initial User Bootstrap: Introduced
SynqConfig.initialUserIdso auto-start sync can target a known user without scanning the entire local dataset
Changed #
- โ๏ธ Auto Sync Initialization:
startAutoSyncnow quietly no-ops when the provided user ID is empty, preventing unnecessary argument errors during startup flows that intentionally defer user selection - ๐ Auto Start Strategy: Auto-start sync now honors the configured initial user instead of loading every local entity up-front, reducing startup work for large data sets
2.1.8 #
Fixed #
- ๐ก๏ธ Remote Sync Regression: Prevent local datasets from being wiped when the remote source returns empty by repopulating remote storage from healthy local data
- ๐งช Regression Coverage: Added unit test ensuring empty-remote scenarios keep local data intact and rehydrate the remote store
2.1.7 #
Added #
- ๐ Remote Metadata Persistence:
RemoteAdapternow exposesupdateSyncMetadataso sync runs persist metadata both locally and remotely for accurate comparisons
Changed #
- ๐งช Integration Coverage: Updated integration tests and example remote adapter to validate remote metadata synchronization
2.1.6 #
Fixed #
- ๐ Initialization State: Fixed initialization state flag to be set before async operations to prevent race conditions during setup
2.1.5 #
Added #
- ๐ External Change Detection: New
changeStream()method onLocalAdapterandchangeStreamgetter onRemoteAdapterto enable real-time change notifications - ๐ก Change Detail Model: New
ChangeDetail<T>model for representing external data changes with metadata (type, entityId, userId, timestamp, sourceId) - ๐ Automatic Change Synchronization: SynqManager now automatically subscribes to adapter change streams and applies external changes to local storage
- ๐ก๏ธ Smart Deduplication: Sophisticated change deduplication system to prevent infinite loops and duplicate processing
- ๐ Change Validation: Multi-level validation checks for external changes (duplicate detection, data currency checks, pending operation checks)
Changed #
- ๐๏ธ SynqManager Refactoring: Major internal refactoring for better maintainability and error handling
- ๐ Enhanced Documentation: Comprehensive inline documentation for all public methods and internal components
- ๐ Immutable Dependencies: Core dependencies are now final and immutable after construction
- โก Improved Initialization: Better initialization flow with proper error handling and logging
- ๐งน Better Resource Management: Enhanced disposal process with subscription cleanup and state validation
Improved #
- ๐ ๏ธ Error Handling: More robust error handling throughout the codebase with detailed logging
- ๐ State Validation: Added disposal state checks to prevent operations after disposal
- ๐ Better Logging: More detailed debug and info logs throughout the synchronization lifecycle
- ๐งช Type Safety: Improved type safety with better use of whereType() instead of where() + cast()
- โ๏ธ Configuration: Better separation of concerns between configuration and runtime state
Removed #
- ๐๏ธ RemoteChangeEvent: Removed in favor of the new
ChangeDetailmodel which is more comprehensive and aligned with sync operations
Fixed #
- ๐ Null Safety: Better null handling in change stream subscriptions and error callbacks
- ๐ง Middleware Error Handling: Improved error handling in middleware transformations
2.1.4 #
Added #
- โจ Auto-Start Sync: New
autoStartSyncconfiguration option to automatically start auto-sync for all users with local data on initialization - ๐ Auto-Start for Multiple Users: Automatically detects all users with local data and starts auto-sync for each
Changed #
- ๐ง Config Rename: Renamed
autoSyncOnConnecttoautoStartSyncfor better clarity - ๐งน Removed Unused Config: Removed
enableRealTimeSyncconfiguration option that was not being used
Improved #
- โ Enhanced Testing: Improved integration tests with proper async handling and cleanup
- ๐ ๏ธ Mock Connectivity Checker: Enhanced mock with proper stream controller and dispose method for better test reliability
Fixed #
- ๐ Test Timing: Fixed test timing issues by adding proper wait for initial events
- ๐งช Test Cleanup: Added proper disposal of connectivity checker in tests to prevent resource leaks
2.1.3 #
Fixed #
- ๐ Critical Error Handling: Fixed catch blocks to properly handle both
ExceptionandErrortypes (e.g.,UnimplementedError) - โ
Lint Compliance: Updated all catch blocks to use
on Object catchsyntax to comply with Dart linting rules - ๐ง onInit Stream: Error handling in initialization now properly catches all throwable types including
UnimplementedError - ๐ง switchUser: Error handling in user switching now properly catches all throwable types
Improved #
- ๐ช Robustness: Enhanced error resilience by catching all error types, not just exceptions
2.1.2 #
Fixed #
- ๐ก๏ธ Error Handling in onInit: Added try-catch block in
onInitstream to gracefully handle errors during initial data fetch - ๐ Error Event Emission: When initial data fetch fails, a
SyncErrorEventis now properly emitted instead of crashing
Improved #
- ๐ช Robustness: Enhanced error resilience in initialization flow
2.1.1 #
Changed #
- โจ Improved
onInitAPI: Simplified initialization flow -onInitstream now automatically fetches and emits initial data on subscription, eliminating the need for manuallisten()call - ๐ Better Documentation: Enhanced documentation for
onInitstream with detailed behavior description and usage examples
Removed #
- ๐๏ธ Deprecated
listen()Method: Removed the standalonelisten()method asonInitstream now handles initialization automatically
2.1.0 #
Added #
- โก Socket-Style Listener API: Introduced
listen(userId)onSynqManagerto deliver an initial dataset snapshot followed by live events through existing streams.
Changed #
- ๐ Initialization Events: New
onInitstream emitsInitialSyncEventpayloads to mirror Socket.IO-style handshake semantics; consumers now receive the full dataset before incremental updates. - ๐งช Integration Coverage: Updated integration tests to validate the new listener flow and force-refresh behavior.
2.0.1 #
Changed #
- ๐ข Version-Driven Conflict Resolution:
LastWriteWinsResolvernow prefers higher numeric versions before falling back to timestamps, enabling accurate ordering after migratingversionfields to integers. - ๐งช Improved Test Coverage: Added regression tests ensuring version comparison precedence and timestamp fallback behavior.
2.0.0 #
Breaking Changes #
- โ ๏ธ Major Version Bump: Significant updates and improvements warranting a major version increase
- ๐ ๏ธ API Changes: Updated APIs for better usability and consistency
1.0.16 #
Fixed #
๐ฏ onInit Callback Issue: Fixed critical timing issue where onInit callbacks were not being triggered
- Implemented
_waitUntilReady()helper method inSynqListenersto ensure manager is fully initialized before setting up listeners - Fixed race condition where
connectedevent was being emitted beforeonInitlisteners were registered - Enhanced all listener methods (onEvent, onCreate, onUpdate, onDelete, onError) to wait for manager readiness
- Improved
onInitreliability by ensuring callback is triggered with all existing data once manager is ready - Better timing control prevents missing initialization events during app startup
Enhanced #
โก Listener Reliability: Improved event listener setup and management
- All listeners now wait for SynqManager to be fully ready before registration
- Eliminated timing-dependent failures in event subscription
- More robust initialization flow ensures consistent callback behavior
- Better separation of concerns between manager initialization and listener setup
1.0.15 #
Fixed #
๐ง User Account Migration Loop: Fixed critical bug causing infinite sync loops during offline data upload
- Fixed missing user ID persistence in
_uploadLocalData()function that caused endless account migration cycles - Added
cloudUserIdparameter to_uploadLocalData()method to ensure user ID is properly stored after successful uploads - Enhanced account conflict resolution to persist user ID in all scenarios (
keepLocalDataaction) - Improved account scenario detection to prevent false positive offline data upload triggers
Enhanced #
๐ Sync Reliability: Improved account migration handling and prevented unnecessary sync repetitions
- Better user ID tracking across different account scenarios (guest sign-in, offline data upload, account switch)
- Enhanced logging and metadata for account scenario debugging
- Optimized sync flow to avoid redundant migration checks after successful user ID persistence
1.0.14 #
Fixed #
๐ Infinite Push Loop: Fixed critical bug where successful push operations caused infinite sync loops
- Added timestamp buffer (1 second) in
_scanForUntrackedChanges()to prevent recently synced items from being detected as new changes - Enhanced
_persistSyncTimestamp()to clear pending changes after successful timestamp persistence - Improved
_pushToCloud()to immediately remove pushed keys from pending changes upon successful completion - Modified sync strategy to exclude successfully pushed items from remote data application, preventing unnecessary re-writes
- Added
excludeKeysparameter to_applyRemoteChanges()to avoid re-applying data that was just pushed - Enhanced
StorageServicewithputWithTimestamp()method for sync operations that preserve original timestamps
Enhanced #
โก Sync Performance: Significantly improved sync efficiency and reliability
- Eliminated redundant local storage writes after successful push operations
- Prevented timestamp conflicts between local and remote data during sync cycles
- Optimized pending changes tracking to avoid false positives
- Better separation between user-initiated changes and sync-related operations
1.0.13 #
Changed #
๐ Code Structure Refactoring: Improved code organization and API structure
- Extracted cloud callback types to separate
CloudCallbacksmodel file - Moved
SyncResultandSyncStatsclasses to dedicated model files for better maintainability - Enhanced type safety with proper CloudFetchResponse structure including
cloudUserIdfield - Updated example app to demonstrate new CloudFetchResponse format
- Improved export structure in main library file for better API access
Added #
โจ Enhanced Cloud Integration: New CloudFetchResponse structure with user identity support
- Added
cloudUserIdfield to CloudFetchResponse for better user tracking - Enhanced metadata support in cloud operations
1.0.12 #
Fixed #
๐ง Delete Sync Issue: Fixed critical bug where deleted items were not being synced to cloud
- Changed delete operation from hard delete to soft delete (marks items as
deleted: true) - Added automatic hard delete after successful cloud sync to maintain storage efficiency
- Ensures all delete operations are properly synchronized with cloud services
Added #
๐๏ธ Hard Delete Support: Added hardDelete() method for permanent local deletion
- Available in both
SynqManagerandStorageService - Bypasses sync and removes items immediately from local storage
- Should be used with caution as it doesn't sync deletions to cloud
Enhanced #
โก Sync Performance: Improved sync service to handle deleted items correctly
- Deleted items are now included in pending changes and synced to cloud
- After successful cloud sync, deleted items are automatically hard deleted locally
- Better storage space management with automatic cleanup of synced deletions
1.0.11 #
Added #
- ๐ Metadata Storage: Implemented metadata storage for sync timestamps in SyncService
- ๐ Empty SyncData Support: Enhanced SynqManager and SyncEvent with empty SyncData support
- ๐ฏ Recent Data Retrieval: Improved pending changes retrieval in SyncService to include recent data
Fixed #
- ๐ง Dependency Management: Reverted hive_plus_secure dependency to stable version 1.1.14 from git reference
- ๐ Debug Logging: Replaced print statements with debugPrint for better error handling and logging consistency
- ๐งน Code Cleanup: Removed debug print statements from storage event handling
Enhanced #
- โก Storage Service: Updated StorageService event handling for better performance
- ๐ก๏ธ Error Management: Improved error handling throughout SynqManager core functionality
- ๐ Sync Performance: Enhanced sync service with better metadata tracking and recent data handling
1.0.10 #
Added #
- ๐ DocumentSerializable Support: Added support for DocumentSerializable interface to SynqManager
- ๐ Enhanced Serialization: Improved data serialization capabilities for better document handling
- ๐ง Storage Service Enhancement: Major improvements to storage service functionality
Enhanced #
- โก SynqManager Core Updates: Refactored core SynqManager implementation for better performance
- ๐ Storage Service Optimization: Streamlined storage service operations (258 additions, 272 deletions)
- ๐ ๏ธ Sync Service Improvements: Enhanced sync service logic for more reliable data synchronization
- ๐ฆ Model Updates: Simplified SyncData model implementation
- ๐ฏ Example Integration: Updated example app to demonstrate new DocumentSerializable features
Technical Improvements #
- ๐ Code Refactoring: Major refactoring across core services for better maintainability
- ๐ API Consistency: Improved API consistency across storage and sync services
- ๐งน Code Cleanup: Removed redundant code and improved overall code quality
1.0.9 #
Fixed #
- ๐ง Duplicate Event Emissions: Fixed critical issue where storage events were being emitted twice
- โก Event Handling Optimization: Removed duplicate event emissions from storage service manual triggers
- ๐ฏ Watcher-Only Events: Streamlined event system to only emit events through Hive watcher
- ๐ Create vs Update Detection: Improved event type detection to properly distinguish between create and update operations
- ๐ Storage Service Refactor: Cleaned up storage service event emission logic for better performance
Enhanced #
- ๐ Single Event Source: All storage events now flow through a single, consistent watcher mechanism
- ๐ Better Performance: Eliminated redundant event processing and improved overall system responsiveness
- ๐ก๏ธ Reliable Event Tracking: Event listeners now receive exactly one event per operation
1.0.8 #
Fixed #
- ๐ง Critical Sync Logic Bug: Fixed major issue where
cloudFetchFunctionwas never called - โก Proper Conflict Detection: Implemented correct conflict detection by fetching remote data first
- ๐ Improved Sync Flow: Restructured sync process to properly use both
cloudFetchFunctionandcloudSyncFunction - ๐ Separation of Concerns:
cloudFetchFunctionnow only handles data fetching,cloudSyncFunctiononly handles data pushing - ๐ Two-Phase Sync: Added separate initial sync and incremental sync modes
- ๐ Better Pending Changes Logic: Fixed logic to only track actual pending changes, not all data
Enhanced #
- ๐ฏ Cleaner Function Responsibilities: Each cloud function now has a single, well-defined responsibility
- ๐ More Efficient Syncing: Reduced unnecessary data transfers and improved sync performance
- ๐ก๏ธ Robust Conflict Handling: Conflicts are now properly detected and handled before data corruption
Breaking Changes #
- โ ๏ธ CloudSyncFunction Behavior:
cloudSyncFunctionshould now only handle pushing data, not conflict detection
1.0.7 #
Added #
- ๐ Cloud Sync Event Tracking: Added detailed event emissions for cloud sync operations
- โ๏ธ CloudSyncFunction Events:
cloudSyncStart,cloudSyncSuccess,cloudSyncErrorevents - ๐ก CloudFetchFunction Events:
cloudFetchStart,cloudFetchSuccess,cloudFetchErrorevents - ๐ Enhanced Metadata: Cloud sync/fetch events include detailed metadata (counts, error info, etc.)
- ๐ฏ Socket.io Style Cloud Events: New listener methods
onCloudSyncStart(),onCloudSyncSuccess(), etc. - ๐ก๏ธ Detailed Error Information: Cloud sync errors now include operation context and metadata
- ๐ Example Integration: Updated example app to demonstrate cloud sync event handling
Enhanced #
- โก Real-time Cloud Operation Tracking: Users can now monitor cloud sync progress in real-time
- ๐จ Better User Experience: Apps can show specific status for cloud operations ("Pushing to cloud...", etc.)
- ๐ Debugging Support: Enhanced error reporting for cloud sync troubleshooting
1.0.6 - 2025-09-24 #
Added #
- ๐ Socket.io Style Event Listeners: Added Socket.io-like event handling with intuitive API
- โจ Builder Pattern Support: Quick setup with fluent
onInit().onCreate().onUpdate().start()pattern - ๐ฏ Granular Event Handling: Separate callbacks for
onInit,onCreate,onUpdate,onDeleteevents - ๐ก Real-time Data Streaming:
onInitprovides all data, other events provide only changed data - ๐ Sync State Management: Built-in
onSyncStartandonSyncCompleteevent handlers - ๐ก๏ธ Error Handling: Dedicated
onErrorcallback for better error management - ๐ Connection State:
onConnectionChangefor network connectivity monitoring - ๐ Comprehensive Documentation: Added detailed usage guide for Socket.io style API
Enhanced #
- ๐ก Developer Experience: More intuitive API similar to Socket.io for web developers
- โก Performance: Optimized event handling with direct data access instead of full reloads
- ๐ง Flexibility: Support for both traditional stream-based and Socket.io style event handling
Examples #
- ๐ Updated Example App: Demonstrates Socket.io style usage with real-time note management
- ๐ Usage Guide: Created comprehensive guide for Socket.io style implementation
1.0.5 #
Added #
- ๐ง Generic Type Serialization: Added
fromJsonandtoJsonfunction parameters toSynqManager.getInstance() - ๐ฆ Custom Object Support: Improved support for complex custom data types with proper JSON serialization/deserialization
- ๐ ๏ธ Type-Safe Serialization: Enhanced type safety for generic types T through configurable serialization functions
Changed #
- โก Breaking Change:
SynqManager.getInstance()now accepts optionalfromJsonandtoJsonparameters for custom object serialization - ๐ Updated Documentation: Enhanced README and example documentation with serialization function usage examples
1.0.4 #
Enhanced #
- ๐ Initial Sync Improvement: First-time connection now automatically syncs all local data to cloud
- ๐ค Complete Data Upload: When
_lastSyncTimestamp == 0, all existing local data is included in the initial sync - ๐ Better Sync Logic: Improved sync behavior for first-time users and fresh installations
1.0.3 #
- new structure
1.0.2 #
Changed #
- ๐ฑ Platform Support: Limited to Android and iOS only due to WorkManager dependency requirements
- ๐งน Removed desktop and web platform files to reduce package size
- ๐ Updated documentation to reflect mobile-only support
Removed #
- ๐๏ธ Linux, macOS, Windows, and Web platform support
- ๐๏ธ Desktop-specific configuration files
1.0.1 #
Fixed #
- ๐ Updated documentation and examples
- ๐ Minor bug fixes and improvements
- โ Package validation improvements
1.0.0 #
Added #
- ๐ Initial release of SynQ Manager
- โก Offline-first synchronization layer for Flutter applications
- ๐ Real-time and configurable sync policies
- ๐ค Guest mode support with account upgrade capability
- ๐ Background synchronization using WorkManager
- ๐ Backend-agnostic architecture:
- CloudAdapter interface for any backend implementation
- No built-in backend dependencies - complete freedom of choice
- Examples for REST API, Supabase, Firebase, and more
- ๐พ Local storage support:
- Hive implementation with type adapters
- Generic LocalStore interface for other storage engines
- โ๏ธ Intelligent conflict resolution:
- Built-in strategies (local wins, remote wins, newer wins, prompt, merge)
- Custom conflict resolver interface
- Automatic conflict detection based on versions and timestamps
- ๐ฏ Type-safe APIs:
- Generic support for any data model
- Strongly typed interfaces throughout
- SyncCacheModel base class for easy integration
- ๐งช Comprehensive testing:
- Unit tests for all core components
- Mock implementations for testing
- Example app demonstrating all features
- ๐ Real-time monitoring:
- Sync status streams
- Conflict event streams
- Network connectivity tracking
- ๐ Production-ready features:
- Error handling and retry logic
- Detailed logging with configurable levels
- Background task scheduling
- Memory-efficient data streaming
Technical Features #
- Mobile platform support: iOS and Android (WorkManager requirement)
- Background sync: Reliable synchronization even when app is closed
- Network awareness: Automatic sync when connectivity is restored
- Data integrity: Version-based conflict detection and resolution
- Scalable architecture: Modular design for easy extension
- Performance optimized: Efficient change tracking and delta sync
Dependencies #
hive: Local storage with type adaptersisar_plus_flutter_libs: Additional storage supportworkmanager: Background task executionflutter_secure_storage: Secure credential storageconnectivity_plus: Network state monitoringsupabase_flutter: Optional Supabase integrationhttp: HTTP client for REST APIs
Documentation #
- Complete README with quick start guide
- API documentation with examples
- Platform-specific setup instructions
- Testing guidelines and examples
- Architecture overview and best practices
Example App #
- Note-taking app demonstrating all features
- Guest mode and account upgrade flow
- Real-time sync with conflict resolution
- Background sync demonstration
- Production-ready code patterns
[Unreleased] #
Planned Features #
- ๐ฑ Enhanced mobile platform support
- ๐ Incremental sync optimizations
- ๐ Analytics and metrics collection
- ๐ GraphQL adapter support
- ๐พ Isar storage adapter
- ๐ Additional cloud service adapters
- ๐จ UI components for common sync patterns