flutter_universal_sync_core 0.3.0
flutter_universal_sync_core: ^0.3.0 copied to clipboard
Core contracts for the flutter_universal_sync offline-first sync package family. Defines the SyncEntity, adapter interfaces, conflict resolver, schema constants, and error hierarchy shared by every ad [...]
Changelog #
0.3.0 — 2026-06-21 #
Added #
PaginatedAdapter— optional capability for keyset (seek) pagination of the local store:getPage(table, {limit, orderBy, descending, after, includeDeleted})returns aPageResult(rows +nextCursor). Keyset anchoring is stable under concurrent inserts/deletes — no offset drift, so no duplicated/skipped rows ("stale reads").InMemoryAdapterimplements it.PageResult/PageCursorvalue types and the sharedpaginateRowshelper (used by stores without a query engine).NetworkState(offline / metered / unmetered) andReachabilityMonitor— refines a raw OS connectivity stream into a confirmed one, optionally verifying real internet with an injected probe (catches captive portals) and de-duplicating. Lets callers defer heavy transfers on metered links.SubmitGuard— prevents duplicate submissions ("triple-tap Save"): keyed single-flight coalescing plus a post-success cooldown. Failures don't cool down, so a failed submit retries immediately.SchemaMigrator/SchemaMigration— versioned local-schema migrations. Runs pending migrations in ascending order, each inside the adapter's transaction with the version bump (stored in the meta KV), so a failed step rolls back and re-runs next launch.SyncPushExceptiongainsisConflict+serverStateso adapters can report a version conflict (HTTP 409) with the server's current row, enabling push-side conflict resolution in the engine.rowFreshness+StalenessPolicy(freshness) — classify a cached row as synced/pending and decide whether table data is too old to trust.runRemoteSyncAdapterContract+RemoteAdapterHarness(intesting.dart) — a shared behavioural contract for remote adapters, mirroringrunLocalDatabaseAdapterContract. Lets a customRemoteSyncAdapterprove it conforms (pull empty/seeded, push insert/update/round-trip/delete).
0.2.1 — 2026-06-21 #
Added #
PurgeableAdapter— optional capability interface for cache eviction, separate from the core adapter contract so adapters opt in without breaking the others.purgeSynced(table, {olderThan, keepLatest})hard-removes synced rows only (never pending), returning the count removed.CacheEvictor— runs amaxAge/maxRowseviction policy across tables on aPurgeableAdapter(injectablenowfor tests).InMemoryAdapternow implementsPurgeableAdapter.
0.2.0 — 2026-04-30 #
Engine-support contract bumps. Required for flutter_universal_sync_engine 0.1.0.
Added #
SyncQueueEntry.nextRetryAtfield; round-trips throughtoMap/fromMap, participates in equality.SyncColumns.nextRetryAtconstant +SyncColumns.queueTypesreference SQL.SyncMetaColumns(table_sync_meta, columnskey,value).LocalDatabaseAdapter.upsert(table, data)— pull-pipeline write.LocalDatabaseAdapter.getMeta(key)/setMeta(key, value)/deleteMeta(key).LocalDatabaseAdapter.pendingForEntity(table, entityId).LocalDatabaseAdapter.rewriteQueuePayload(entryId, payload).LocalDatabaseAdapter.pendingSyncEntries(...)gains areadyAtparameter (back-compat with the existing{int? limit}form).- Contract-suite groups for every addition above; reusable by every adapter.
InMemoryAdapteris now exported frompackage:flutter_universal_sync_core/testing.dartso downstream packages (e.g. the sync engine) can reuse it as a local-store test double.
Changed #
LocalDatabaseAdapter.recordSyncFailure(...)now incrementsretry_countand acceptsnextRetryAt. PassincrementRetryCount: falseand omitnextRetryAtto retain 0.1.0 "just store the error" behaviour.
Migration (for 0.1.0 adapters; none published yet) #
- Add
next_retry_at INTEGERto your sync queue table. - Create
_sync_meta(key TEXT PRIMARY KEY, value TEXT NOT NULL). - Implement the seven new / amended methods above.
- The shared contract suite exercises every new method — run it.
0.1.0 — 2026-04-24 #
Initial release. Contracts layer for the flutter_universal_sync family.
Added #
SyncEntityabstract base class with the six sync-metadata fields.SyncQueueEntrydata class withcopyWith,toMap/fromMap, and structural equality.SyncOperation(insert/update/delete) andSyncStatus(pending/syncing/synced/failed) enums.LocalDatabaseAdapterinterface covering domain CRUD, sync queue, atomic transactions, and schema validation.RemoteSyncAdapterinterface for per-op push and delta pull.ConflictResolverinterface plus three built-in strategies:LastWriteWinsResolver,ServerPriorityResolver,ClientPriorityResolver.SyncColumnsschema constants.SyncExceptionsealed hierarchy (SchemaValidationException,SyncPushException,SyncPullException,ConflictResolutionException).IdGenerator/UuidV4Generator.- Shared
runLocalDatabaseAdapterContracttest suite for downstream adapter packages (exported viapackage:flutter_universal_sync_core/testing.dart).
Known limitations #
See README "Known v1 limitations" for the list of accepted 0.1.0 trade-offs.