diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 54ada2ac..8a80925f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -39,9 +39,12 @@ jobs: run: dart test - name: Generate coverage if: runner.os == 'macOS' - run: dart run coverage:test_with_coverage + run: dart run test --coverage=coverage + - name: Convert to lcov + run: dart pub global run coverage:format_coverage --in="./coverage/test" --out="./coverage/lcov.info" --lcov --report-on="./lib" - name: Send coverage report to codecov if: runner.os == 'macOS' - uses: codecov/codecov-action@v1 + uses: codecov/codecov-action@v4 with: + files: ./coverage/lcov.info token: ${{ secrets.CODECOV_TOKEN }} diff --git a/example/lib/models/task.g.dart b/example/lib/models/task.g.dart index 1b54ec53..aa68ef3e 100644 --- a/example/lib/models/task.g.dart +++ b/example/lib/models/task.g.dart @@ -62,7 +62,7 @@ extension TaskRelationshipGraphNodeX on RelationshipGraphNode { // ************************************************************************** Task _$TaskFromJson(Map json) => Task( - id: json['id'] as int?, + id: (json['id'] as num?)?.toInt(), title: json['title'] as String, completed: json['completed'] as bool? ?? false, user: json['userId'] == null diff --git a/example/lib/models/user.g.dart b/example/lib/models/user.g.dart index dac5faf3..80e1eac3 100644 --- a/example/lib/models/user.g.dart +++ b/example/lib/models/user.g.dart @@ -62,7 +62,7 @@ extension UserRelationshipGraphNodeX on RelationshipGraphNode { // ************************************************************************** User _$UserFromJson(Map json) => User( - id: json['id'] as int?, + id: (json['id'] as num?)?.toInt(), name: json['name'] as String, tasks: json['tasks'] == null ? null diff --git a/example/pubspec.lock b/example/pubspec.lock index 00266031..88611d5e 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -191,7 +191,7 @@ packages: path: ".." relative: true source: path - version: "2.0.0-rc2" + version: "2.0.0-rc3" frontend_server_client: dependency: transitive description: @@ -296,14 +296,6 @@ packages: url: "https://pub.dev" source: hosted version: "0.12.16+1" - messagepack: - dependency: transitive - description: - name: messagepack - sha256: "11e69dd79ba84ba901261558881b42ac8b24155a7846a344875a32c8b0866d71" - url: "https://pub.dev" - source: hosted - version: "0.2.1" meta: dependency: transitive description: @@ -360,22 +352,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.2.3" - recase: - dependency: transitive - description: - name: recase - sha256: e4eb4ec2dcdee52dcf99cb4ceabaffc631d7424ee55e56f280bc039737f89213 - url: "https://pub.dev" - source: hosted - version: "4.1.0" - retry: - dependency: transitive - description: - name: retry - sha256: "822e118d5b3aafed083109c72d5f484c6dc66707885e07c0fbcb8b986bba7efc" - url: "https://pub.dev" - source: hosted - version: "3.1.2" riverpod: dependency: transitive description: diff --git a/example/pubspec.yaml b/example/pubspec.yaml index e2730564..3e699bc3 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -9,8 +9,8 @@ environment: dependencies: flutter_data: path: ../../flutter_data - json_annotation: ^4.8.0 + json_annotation: ^4.9.0 dev_dependencies: build_runner: ^2.0.4 - json_serializable: ^6.1.3 + json_serializable: ^6.8.0 diff --git a/lib/flutter_data.dart b/lib/flutter_data.dart index 85c6989e..4618ecb1 100644 --- a/lib/flutter_data.dart +++ b/lib/flutter_data.dart @@ -14,7 +14,6 @@ import 'package:http/http.dart' as http; import 'package:inflection3/inflection3.dart' as inflection; import 'package:meta/meta.dart'; import 'package:path/path.dart' as path_helper; -import 'package:pool/pool.dart'; import 'package:riverpod/riverpod.dart'; import 'package:sqlite3/sqlite3.dart'; import 'package:state_notifier/state_notifier.dart'; diff --git a/lib/src/utils/extensions.dart b/lib/src/utils/extensions.dart index 4f0cff30..29717676 100644 --- a/lib/src/utils/extensions.dart +++ b/lib/src/utils/extensions.dart @@ -26,10 +26,6 @@ extension _DataModelListX on Iterable { } } -extension _ListX on List { - T? getSafe(int index) => (length > index) ? this[index] : null; -} - extension DynamicX on dynamic { String typifyWith(String type) { final _this = this.toString(); diff --git a/lib/src/utils/offline_operations.dart b/lib/src/utils/offline_operations.dart index 9ee27e31..8917b209 100644 --- a/lib/src/utils/offline_operations.dart +++ b/lib/src/utils/offline_operations.dart @@ -131,57 +131,3 @@ extension OfflineOperationsX on Set> { // stores onSuccess/onError function combos final _offlineCallbackProvider = StateProvider>((_) => {}); - -// providers - -final offlineRetryProvider = StreamProvider((ref) async* { - Set _offlineOperations() { - return _internalAdaptersMap!.values - .map((adapter) { - // if the stream is called before initialization - // (or after disposal) simply return an empty set - if (!adapter.isInitialized) { - return {}; - } - return adapter.offlineOperations; - }) - .expand((e) => e) - .toSet(); - } - - final pool = Pool(4, timeout: Duration(seconds: 30)); - - var _counter = 0; - - while (true) { - // sort operations by timestamp - final ops = _offlineOperations().toList() - ..sort((a, b) => a.timestamp.compareTo(b.timestamp)); - - if (ops.isEmpty) { - _counter = 0; - await Future.delayed(Duration(milliseconds: backoffFn(4))); - continue; - } - - print( - '[offline] retrying ${ops.length} operations: ${ops.map((op) => op.label)}'); - - try { - final result = pool.forEach( - ops, - (OfflineOperation op) async => op.retry(), - ); - await for (final _ in result) {} - } finally { - final duration = - Duration(milliseconds: backoffFn(_counter) + ops.length * 50); - print('[offline] waiting $duration to try again'); - await Future.delayed(duration); - _counter++; - } - } -}); - -final backoffFn = - (int i) => [400, 800, 1600, 3200, 6400, 12800, 12800].getSafe(i) ?? 25600; diff --git a/pubspec.lock b/pubspec.lock index 4c8912ef..c454cc83 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -10,7 +10,7 @@ packages: source: hosted version: "67.0.0" analyzer: - dependency: "direct main" + dependency: transitive description: name: analyzer sha256: "37577842a27e4338429a1cbc32679d508836510b056f1eedf0c8d20e39c1383d" @@ -26,7 +26,7 @@ packages: source: hosted version: "2.5.0" async: - dependency: "direct main" + dependency: transitive description: name: async sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" @@ -146,7 +146,7 @@ packages: source: hosted version: "3.1.1" coverage: - dependency: "direct dev" + dependency: transitive description: name: coverage sha256: "8acabb8306b57a409bf4c83522065672ee13179297a6bb0cb9ead73948df7c76" @@ -154,7 +154,7 @@ packages: source: hosted version: "1.7.2" crypto: - dependency: "direct main" + dependency: transitive description: name: crypto sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab @@ -306,7 +306,7 @@ packages: source: hosted version: "0.7.1" json_annotation: - dependency: "direct main" + dependency: "direct dev" description: name: json_annotation sha256: "1ce844379ca14835a50d2f019a3099f419082cfdd231cd86a142af94dd5c6bb1" @@ -345,14 +345,6 @@ packages: url: "https://pub.dev" source: hosted version: "0.12.16+1" - messagepack: - dependency: "direct main" - description: - name: messagepack - sha256: "11e69dd79ba84ba901261558881b42ac8b24155a7846a344875a32c8b0866d71" - url: "https://pub.dev" - source: hosted - version: "0.2.1" meta: dependency: "direct main" description: @@ -402,7 +394,7 @@ packages: source: hosted version: "1.9.0" pool: - dependency: "direct main" + dependency: transitive description: name: pool sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a" @@ -425,22 +417,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.2.3" - recase: - dependency: "direct main" - description: - name: recase - sha256: e4eb4ec2dcdee52dcf99cb4ceabaffc631d7424ee55e56f280bc039737f89213 - url: "https://pub.dev" - source: hosted - version: "4.1.0" - retry: - dependency: "direct main" - description: - name: retry - sha256: "822e118d5b3aafed083109c72d5f484c6dc66707885e07c0fbcb8b986bba7efc" - url: "https://pub.dev" - source: hosted - version: "3.1.2" riverpod: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index bc4ef142..0a5fd354 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -10,25 +10,17 @@ environment: sdk: ">=3.1.0 <4.0.0" dependencies: - analyzer: ^6.4.0 - async: ^2.6.1 build: ^2.0.2 build_resolvers: ^2.0.10 collection: ^1.16.0 - crypto: ^3.0.1 equatable: ^2.0.2 glob: ^2.0.1 - http: ^1.2.0 + http: ^1.2.1 inflection3: ^0.5.3+2 - json_annotation: ^4.8.1 - messagepack: ^0.2.1 meta: ^1.7.0 path: ^1.8.0 - pool: ^1.5.1 pubspec_parse: ^1.0.0 - recase: ^4.0.0 - retry: ^3.1.0 - riverpod: ^2.1.1 + riverpod: ^2.5.1 source_gen: ^1.0.1 source_helper: ^1.3.2 sqlite3: ^2.4.2 @@ -37,10 +29,10 @@ dependencies: dev_dependencies: build_runner: ^2.3.0 build_test: ^2.1.0 - coverage: ^1.3.2 - freezed: ^2.3.0 + freezed: ^2.5.2 freezed_annotation: ^2.0.1 - json_serializable: ^6.6.1 + json_annotation: ^4.9.0 + json_serializable: ^6.8.0 lints: ^3.0.0 matcher: ^0.12.10 mockito: ^5.0.9 diff --git a/test/_support/book.freezed.dart b/test/_support/book.freezed.dart index f03cc9ea..801676ca 100644 --- a/test/_support/book.freezed.dart +++ b/test/_support/book.freezed.dart @@ -12,7 +12,7 @@ part of 'book.dart'; T _$identity(T value) => value; final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); BookAuthor _$BookAuthorFromJson(Map json) { return _BookAuthor.fromJson(json); diff --git a/test/_support/book.g.dart b/test/_support/book.g.dart index 13826e86..b421e90e 100644 --- a/test/_support/book.g.dart +++ b/test/_support/book.g.dart @@ -188,7 +188,7 @@ extension LibraryRelationshipGraphNodeX on RelationshipGraphNode { _$BookAuthorImpl _$$BookAuthorImplFromJson(Map json) => _$BookAuthorImpl( - id: json['id'] as int, + id: (json['id'] as num).toInt(), name: json['name'] as String?, books: HasMany.fromJson(json['books'] as Map), ); @@ -201,9 +201,9 @@ Map _$$BookAuthorImplToJson(_$BookAuthorImpl instance) => }; _$BookImpl _$$BookImplFromJson(Map json) => _$BookImpl( - id: json['id'] as int, + id: (json['id'] as num).toInt(), title: json['title'] as String?, - numberOfSales: json['number_of_sales'] as int? ?? 0, + numberOfSales: (json['number_of_sales'] as num?)?.toInt() ?? 0, originalAuthor: json['original_author_id'] == null ? null : BelongsTo.fromJson( @@ -236,7 +236,7 @@ Map _$$BookImplToJson(_$BookImpl instance) { _$LibraryImpl _$$LibraryImplFromJson(Map json) => _$LibraryImpl( - id: json['id'] as int, + id: (json['id'] as num).toInt(), name: json['name'] as String, books: HasMany.fromJson(json['books'] as Map), ); diff --git a/test/_support/node.freezed.dart b/test/_support/node.freezed.dart index d0a3c63a..9bbc86fe 100644 --- a/test/_support/node.freezed.dart +++ b/test/_support/node.freezed.dart @@ -12,7 +12,7 @@ part of 'node.dart'; T _$identity(T value) => value; final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); Node _$NodeFromJson(Map json) { return _Node.fromJson(json); diff --git a/test/_support/node.g.dart b/test/_support/node.g.dart index 8aa26978..e2a8975c 100644 --- a/test/_support/node.g.dart +++ b/test/_support/node.g.dart @@ -77,7 +77,7 @@ extension NodeRelationshipGraphNodeX on RelationshipGraphNode { // ************************************************************************** _$NodeImpl _$$NodeImplFromJson(Map json) => _$NodeImpl( - id: json['id'] as int?, + id: (json['id'] as num?)?.toInt(), name: json['name'] as String?, parent: json['parent'] == null ? null