From 305fba3e7e5617636212d2368c0f4de8d85ed908 Mon Sep 17 00:00:00 2001 From: Santiago Garcia Gil Date: Tue, 24 Sep 2024 15:07:19 -0500 Subject: [PATCH 1/3] feat: Add Channel Message to subscribeTo --- clients/client-dart/CHANGELOG.md | 1 + clients/client-dart/analysis_options.yaml | 111 +----------------- .../lib/channel_sender_client.dart | 3 +- clients/client-dart/lib/src/async_client.dart | 18 +-- .../client-dart/lib/src/channel_message.dart | 16 +-- clients/client-dart/pubspec.lock | 62 +++++----- clients/client-dart/pubspec.yaml | 6 +- 7 files changed, 62 insertions(+), 155 deletions(-) diff --git a/clients/client-dart/CHANGELOG.md b/clients/client-dart/CHANGELOG.md index 47490d6..b96a334 100644 --- a/clients/client-dart/CHANGELOG.md +++ b/clients/client-dart/CHANGELOG.md @@ -1,5 +1,6 @@ # CHANGELOG +## [2.0.0] - Add Channel Message to `subscribeTo` ## [1.0.2] - Add Dart Code Linter ## [1.0.1] - Update of dependencies to comply with null safety definition ## [1.0.0] - First version of channel_sender_client diff --git a/clients/client-dart/analysis_options.yaml b/clients/client-dart/analysis_options.yaml index caf5b61..6a21cae 100644 --- a/clients/client-dart/analysis_options.yaml +++ b/clients/client-dart/analysis_options.yaml @@ -1,58 +1,4 @@ include: package:flutter_lints/flutter.yaml - -linter: - rules: - avoid_print: true - avoid_unnecessary_containers: true - avoid_web_libraries_in_flutter: true - no_logic_in_create_state: false - prefer_const_constructors: true - prefer_const_constructors_in_immutables: true - prefer_const_declarations: true - prefer_const_literals_to_create_immutables: true - sized_box_for_whitespace: true - use_full_hex_values_for_flutter_colors: true - always_declare_return_types: true - cancel_subscriptions: true - close_sinks: true - comment_references: false - one_member_abstracts: false - only_throw_errors: true - package_api_docs: true - prefer_single_quotes: true - sort_child_properties_last: true - camel_case_types: true - library_names: true - file_names: true - library_prefixes: true - non_constant_identifier_names: true - constant_identifier_names: false - directives_ordering: true - curly_braces_in_flow_control_structures: true - slash_for_doc_comments: false - prefer_interpolation_to_compose_strings: true - prefer_collection_literals: true - avoid_function_literals_in_foreach_calls: false - avoid_init_to_null: true - prefer_initializing_formals: true - type_init_formals: true - empty_constructor_bodies: true - empty_statements: true - unnecessary_new: true - unnecessary_this: true - unnecessary_const: true - unnecessary_overrides: true - unnecessary_parenthesis: true - unnecessary_getters_setters: true - avoid_setters_without_getters: true - avoid_return_types_on_setters: true - parameter_assignments: true - prefer_function_declarations_over_variables: false - unawaited_futures: true - prefer_relative_imports: true - annotate_overrides: false - overridden_fields: false - analyzer: errors: missing_required_param: error @@ -64,57 +10,8 @@ analyzer: todo: warning plugins: - dart_code_linter - + dart_code_linter: - metrics: - cyclomatic-complexity: 20 - maximum-nesting-level: 5 - maintainability-index: 50 - number-of-methods: 10 - number-of-parameters: 4 - source-lines-of-code: 250 - metrics-exclude: - - test/** - rules: - - avoid-non-null-assertion - - avoid-dynamic - - avoid-returning-widgets - - avoid-nested-conditional-expressions - - avoid-unnecessary-type-casts - - avoid-unnecessary-conditionals - - avoid-unused-parameters - - missing-test-assertion - - newline-before-return - - no-boolean-literal-compare - - no-empty-block - - no-equal-then-else - - no-magic-number - - prefer-trailing-comma - - prefer-conditional-expressions - - prefer-immediate-return - - prefer-moving-to-variable - - format-comment: - only-doc-comments: true - - member-ordering: - order: - - constructors - - public-fields - - private-fields - - close-method - - dispose-method - widgets-order: - - constructor - - build-method - - init-state-method - - did-change-dependencies-method - - did-update-widget-method - - dispose-method - #Flutter - - always-remove-listener - - avoid-unnecessary-setstate - - prefer-extracting-callbacks - - prefer-using-list-view - - anti-patterns: - - long-method - - long-parameter-list + extends: + - package:dart_code_linter/presets/recommended.yaml + \ No newline at end of file diff --git a/clients/client-dart/lib/channel_sender_client.dart b/clients/client-dart/lib/channel_sender_client.dart index e42e32c..571984c 100644 --- a/clients/client-dart/lib/channel_sender_client.dart +++ b/clients/client-dart/lib/channel_sender_client.dart @@ -1,2 +1,3 @@ export 'src/async_client.dart' show AsyncClient; -export 'src/async_config.dart' show AsyncConfig; \ No newline at end of file +export 'src/async_config.dart' show AsyncConfig; +export 'src/channel_message.dart'; diff --git a/clients/client-dart/lib/src/async_client.dart b/clients/client-dart/lib/src/async_client.dart index 52be11a..66e0361 100644 --- a/clients/client-dart/lib/src/async_client.dart +++ b/clients/client-dart/lib/src/async_client.dart @@ -108,13 +108,13 @@ class AsyncClient { } StreamSubscription subscribeTo( - String eventFilter, Function onData, - {Function? onError}) { - if (onError != null) { - return subscribeToMany([eventFilter], onData, onError: onError); - } else { - return subscribeToMany([eventFilter], onData); - } + String eventFilter, + Function(ChannelMessage) onData, { + Function? onError, + }) { + return onError != null + ? subscribeToMany([eventFilter], onData, onError: onError) + : subscribeToMany([eventFilter], onData); } StreamSubscription subscribeToMany( @@ -123,11 +123,11 @@ class AsyncClient { if (eventFilters == null || eventFilters.isEmpty) { throw ArgumentError('Invalid event filter(s)'); } else { - eventFilters.forEach((element) { + for (var element in eventFilters) { if (element.trim().isEmpty) { throw ArgumentError('Invalid event filter'); } - }); + } } if (onData == null) { throw ArgumentError('Invalid onData function'); diff --git a/clients/client-dart/lib/src/channel_message.dart b/clients/client-dart/lib/src/channel_message.dart index d2df75c..e6e7d59 100644 --- a/clients/client-dart/lib/src/channel_message.dart +++ b/clients/client-dart/lib/src/channel_message.dart @@ -1,19 +1,19 @@ class ChannelMessage { + ChannelMessage(this.messageId, this.correlationId, this.event, this.payload); + + ChannelMessage.fromMap(Map map) + : messageId = map['message_id'], + correlationId = map['correlation_id'], + event = map['event'], + payload = map['payload']; + final String? messageId; final String? correlationId; final String? event; dynamic payload; - ChannelMessage(this.messageId, this.correlationId, this.event, this.payload); - @override String toString() { return '{messageId: $messageId, correlationId: $correlationId, event: $event, payload: $payload }'; } - - ChannelMessage.fromMap(dynamic map) - : messageId = map['message_id'], - correlationId = map['correlation_id'], - event = map['event'], - payload = map['payload']; } diff --git a/clients/client-dart/pubspec.lock b/clients/client-dart/pubspec.lock index 2e05eec..ca32423 100644 --- a/clients/client-dart/pubspec.lock +++ b/clients/client-dart/pubspec.lock @@ -5,18 +5,18 @@ packages: dependency: transitive description: name: _fe_analyzer_shared - sha256: e440ac42679dfc04bbbefb58ed225c994bc7e07fccc8a68ec7d3631a127e5da9 + sha256: ae92f5d747aee634b87f89d9946000c2de774be1d6ac3e58268224348cd0101a url: "https://pub.dev" source: hosted - version: "54.0.0" + version: "61.0.0" analyzer: dependency: transitive description: name: analyzer - sha256: "2c2e3721ee9fb36de92faa060f3480c81b23e904352b087e5c64224b1a044427" + sha256: ea3d8652bda62982addfd92fdc2d0214e5f82e43325104990d4f4c4a2a313562 url: "https://pub.dev" source: hosted - version: "5.6.0" + version: "5.13.0" analyzer_plugin: dependency: transitive description: @@ -29,10 +29,10 @@ packages: dependency: transitive description: name: ansicolor - sha256: "607f8fa9786f392043f169898923e6c59b4518242b68b8862eb8a8b7d9c30b4a" + sha256: "50e982d500bc863e1d703448afdbf9e5a72eb48840a4f766fa361ffd6877055f" url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "2.0.3" args: dependency: transitive description: @@ -173,18 +173,18 @@ packages: dependency: transitive description: name: csslib - sha256: b36c7f7e24c0bdf1bf9a3da461c837d1de64b9f8beb190c9011d8c72a3dfd745 + sha256: "706b5707578e0c1b4b7550f64078f0a0f19dec3f50a178ffae7006b0a9ca58fb" url: "https://pub.dev" source: hosted - version: "0.17.2" + version: "1.0.0" dart_code_linter: dependency: "direct dev" description: name: dart_code_linter - sha256: e9c2764a39033ad808269092d8ae90b7c696598d2cd2138681550edf85be735f + sha256: "06fe4081e9e376917fbbdaf8f590162ae20bbcb29245e18a7f6f80557197ce16" url: "https://pub.dev" source: hosted - version: "1.1.1" + version: "1.1.4" dart_style: dependency: transitive description: @@ -245,18 +245,18 @@ packages: dependency: transitive description: name: html - sha256: "58e3491f7bf0b6a4ea5110c0c688877460d1a6366731155c4a4580e7ded773e8" + sha256: "3a7812d5bcd2894edf53dfaf8cd640876cf6cef50a8f238745c8b8120ea74d3a" url: "https://pub.dev" source: hosted - version: "0.15.3" + version: "0.15.4" http: dependency: transitive description: name: http - sha256: "6aa2946395183537c8b880962d935877325d6a09a2867c3970c05c0fed6ac482" + sha256: "759d1a329847dd0f39226c688d3e06a6b8679668e350e2891a6474f8b4bb8525" url: "https://pub.dev" source: hosted - version: "0.13.5" + version: "1.1.0" http_multi_server: dependency: transitive description: @@ -373,18 +373,18 @@ packages: dependency: transitive description: name: petitparser - sha256: "49392a45ced973e8d94a85fdb21293fbb40ba805fc49f2965101ae748a3683b4" + sha256: eeb2d1428ee7f4170e2bd498827296a18d4e7fc462b71727d111c0ac7707cfa6 url: "https://pub.dev" source: hosted - version: "5.1.0" + version: "6.0.1" platform: dependency: transitive description: name: platform - sha256: "57c07bf82207aee366dfaa3867b3164e4f03a238a461a11b0e8a3a510d51203d" + sha256: "12220bb4b65720483f8fa9450b4332347737cf8213dd2840d8b2c823e47243ec" url: "https://pub.dev" source: hosted - version: "3.1.1" + version: "3.1.4" pool: dependency: transitive description: @@ -397,10 +397,10 @@ packages: dependency: transitive description: name: process - sha256: "53fd8db9cec1d37b0574e12f07520d582019cb6c44abf5479a01505099a34a09" + sha256: "21e54fd2faf1b5bdd5102afd25012184a6793927648ea81eea80552ac9405b32" url: "https://pub.dev" source: hosted - version: "4.2.4" + version: "5.0.2" pub_semver: dependency: transitive description: @@ -413,10 +413,10 @@ packages: dependency: transitive description: name: pub_updater - sha256: "05ae70703e06f7fdeb05f7f02dd680b8aad810e87c756a618f33e1794635115c" + sha256: "54e8dc865349059ebe7f163d6acce7c89eb958b8047e6d6e80ce93b13d7c9e60" url: "https://pub.dev" source: hosted - version: "0.3.0" + version: "0.4.0" pubspec_parse: dependency: transitive description: @@ -489,6 +489,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.10.0" + sprintf: + dependency: transitive + description: + name: sprintf + sha256: "1fc9ffe69d4df602376b52949af107d8f5703b77cda567c4d7d86a0693120f23" + url: "https://pub.dev" + source: hosted + version: "7.0.0" stack_trace: dependency: transitive description: @@ -573,10 +581,10 @@ packages: dependency: "direct main" description: name: uuid - sha256: "648e103079f7c64a36dc7d39369cabb358d377078a051d6ae2ad3aa539519313" + sha256: "8c951c9cb6504b2aa6b3666e6de504032d9baec24bf4cbabd3eea9edd73d4d77" url: "https://pub.dev" source: hosted - version: "3.0.7" + version: "4.3.2" validators: dependency: "direct main" description: @@ -621,10 +629,10 @@ packages: dependency: transitive description: name: xml - sha256: "979ee37d622dec6365e2efa4d906c37470995871fe9ae080d967e192d88286b5" + sha256: af5e77e9b83f2f4adc5d3f0a4ece1c7f45a2467b695c2540381bac793e34e556 url: "https://pub.dev" source: hosted - version: "6.2.2" + version: "6.4.2" yaml: dependency: transitive description: @@ -634,4 +642,4 @@ packages: source: hosted version: "3.1.1" sdks: - dart: ">=2.19.0 <3.0.0" + dart: ">=3.0.0 <4.0.0" diff --git a/clients/client-dart/pubspec.yaml b/clients/client-dart/pubspec.yaml index b230f1b..b779dea 100644 --- a/clients/client-dart/pubspec.yaml +++ b/clients/client-dart/pubspec.yaml @@ -1,6 +1,6 @@ name: channel_sender_client description: Client for Async DataFlow Channel Sender -version: 1.0.2 +version: 2.0.0 homepage: https://github.com/bancolombia/async-dataflow repository: https://github.com/bancolombia/async-dataflow.git @@ -11,11 +11,11 @@ dependencies: web_socket_channel: ^2.3.0 logging: ^1.1.0 validators: ^3.0.0 - uuid: ^3.0.7 + uuid: ^4.1.0 build_runner: ^2.2.0 dev_dependencies: test: ^1.21.4 mockito: ^5.2.0 - dart_code_linter: ^1.1.1 flutter_lints: ^2.0.3 + dart_code_linter: ^1.1.4 From bfde257b194c78f71bac4a42b143da1975fd0a74 Mon Sep 17 00:00:00 2001 From: Santiago Garcia Gil Date: Tue, 24 Sep 2024 15:16:38 -0500 Subject: [PATCH 2/3] feat: Add Channel Message to subscribeTo --- clients/client-dart/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/client-dart/pubspec.yaml b/clients/client-dart/pubspec.yaml index b779dea..59d5daf 100644 --- a/clients/client-dart/pubspec.yaml +++ b/clients/client-dart/pubspec.yaml @@ -5,7 +5,7 @@ homepage: https://github.com/bancolombia/async-dataflow repository: https://github.com/bancolombia/async-dataflow.git environment: - sdk: ">=2.12.0 <3.0.0" + sdk: '>=3.0.0 <4.0.0' dependencies: web_socket_channel: ^2.3.0 From c798ecc359ce05d3c5351f0ebd46eb28272f30eb Mon Sep 17 00:00:00 2001 From: Santiago Garcia Gil Date: Tue, 24 Sep 2024 15:34:26 -0500 Subject: [PATCH 3/3] feat: Add Channel Message to subscribeTo --- .github/workflows/build-client-dart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-client-dart.yaml b/.github/workflows/build-client-dart.yaml index d1ff283..e86fe88 100644 --- a/.github/workflows/build-client-dart.yaml +++ b/.github/workflows/build-client-dart.yaml @@ -20,7 +20,7 @@ jobs: uses: flutter-actions/setup-flutter@v2 with: channel: stable - version: 3.7.12 + version: 3.10.6 - name: Install dependencies run: flutter pub get - name: Run test