From 57ed708bfe351f64abe1ce82ec119493b5c01e51 Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Mon, 15 May 2023 13:59:06 +0530 Subject: [PATCH 01/12] fix: timetoken parsing for web app compatibility --- pubnub/lib/src/dx/_endpoints/history.dart | 4 ++-- pubnub/lib/src/dx/time.dart | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pubnub/lib/src/dx/_endpoints/history.dart b/pubnub/lib/src/dx/_endpoints/history.dart index 16a7e58b..c4847cb6 100644 --- a/pubnub/lib/src/dx/_endpoints/history.dart +++ b/pubnub/lib/src/dx/_endpoints/history.dart @@ -65,8 +65,8 @@ class FetchHistoryResult extends Result { if (object is List) { return FetchHistoryResult._( object[0], - Timetoken(BigInt.from(object[1] as int)), - Timetoken(BigInt.from(object[2] as int))); + Timetoken(BigInt.parse(object[1])), + Timetoken(BigInt.parse(object[2]))); } throw getExceptionFromAny(object); diff --git a/pubnub/lib/src/dx/time.dart b/pubnub/lib/src/dx/time.dart index e39d4088..57c00eb4 100644 --- a/pubnub/lib/src/dx/time.dart +++ b/pubnub/lib/src/dx/time.dart @@ -9,6 +9,6 @@ mixin TimeDx on Core { return defaultFlow( core: this, params: TimeParams(), - serialize: (object, [_]) => Timetoken(BigInt.from(object[0] as int))); + serialize: (object, [_]) => Timetoken(BigInt.parse(object[0]))); } } From 3d5caec6462c91003c89bf78e1f2200d24300542 Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Wed, 17 May 2023 11:30:00 +0530 Subject: [PATCH 02/12] format --- .../lib/src/hooks/mock_server_hook.dart | 20 +++++++++++-------- acceptance_tests/lib/src/reporter.dart | 3 ++- pubnub/lib/src/dx/_endpoints/history.dart | 4 +--- pubnub/test/unit/net/utils.dart | 7 +++++-- 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/acceptance_tests/lib/src/hooks/mock_server_hook.dart b/acceptance_tests/lib/src/hooks/mock_server_hook.dart index f2f016c6..a0cbe7d2 100644 --- a/acceptance_tests/lib/src/hooks/mock_server_hook.dart +++ b/acceptance_tests/lib/src/hooks/mock_server_hook.dart @@ -13,13 +13,17 @@ class MockServerHook extends Hook { Iterable tags, ) async { try { - var tagParts = tags.firstWhere((element) => element.name.startsWith('@contract=')).name.split('='); + var tagParts = tags + .firstWhere((element) => element.name.startsWith('@contract=')) + .name + .split('='); var contract = tagParts.skip(1).first; // await Future.delayed(Duration(seconds: 3)); - var res = await http.get(Uri.parse('http://localhost:8090/init?__contract__script__=$contract')); + var res = await http.get(Uri.parse( + 'http://localhost:8090/init?__contract__script__=$contract')); // check for 200 response and fail scenario if not 200 @@ -35,8 +39,8 @@ class MockServerHook extends Hook { int myData = 0; @override - Future onAfterStep( - covariant PubNubWorld world, ScenarioRunnable scenario, String step, StepResult stepResult) async { + Future onAfterStep(covariant PubNubWorld world, + ScenarioRunnable scenario, String step, StepResult stepResult) async { // print( // 'Hook step: $step, result: ${stepResult.result} ${stepResult.resultReason}'); @@ -58,12 +62,12 @@ class MockServerHook extends Hook { // '[Hook] x ${failedExp.length}, . ${pendingExp.length}, v ${succeededExp.length}'); if (failedExp.isNotEmpty) { - return StepResult( - stepResult.elapsedMilliseconds, StepExecutionResult.fail, 'Failed expectations: $failedExp.'); + return StepResult(stepResult.elapsedMilliseconds, + StepExecutionResult.fail, 'Failed expectations: $failedExp.'); } } catch (e) { - return StepResult( - stepResult.elapsedMilliseconds, StepExecutionResult.error, 'Unable to verify expectations: $e.'); + return StepResult(stepResult.elapsedMilliseconds, + StepExecutionResult.error, 'Unable to verify expectations: $e.'); } } diff --git a/acceptance_tests/lib/src/reporter.dart b/acceptance_tests/lib/src/reporter.dart index 5c8c7eab..af4050a9 100644 --- a/acceptance_tests/lib/src/reporter.dart +++ b/acceptance_tests/lib/src/reporter.dart @@ -142,6 +142,7 @@ class PubNubReporter extends Reporter { print(''); print(' $scenarioCount scenarios executed'); print('${Color.PASS}✓${Color.RESET} $passedScenarioCount scenarios passed'); - print('${Color.FAIL}x${Color.RESET} ${scenarioCount - passedScenarioCount} scenarios failed'); + print( + '${Color.FAIL}x${Color.RESET} ${scenarioCount - passedScenarioCount} scenarios failed'); } } diff --git a/pubnub/lib/src/dx/_endpoints/history.dart b/pubnub/lib/src/dx/_endpoints/history.dart index c4847cb6..de3747c8 100644 --- a/pubnub/lib/src/dx/_endpoints/history.dart +++ b/pubnub/lib/src/dx/_endpoints/history.dart @@ -63,9 +63,7 @@ class FetchHistoryResult extends Result { factory FetchHistoryResult.fromJson(dynamic object) { if (object is List) { - return FetchHistoryResult._( - object[0], - Timetoken(BigInt.parse(object[1])), + return FetchHistoryResult._(object[0], Timetoken(BigInt.parse(object[1])), Timetoken(BigInt.parse(object[2]))); } diff --git a/pubnub/test/unit/net/utils.dart b/pubnub/test/unit/net/utils.dart index 308c7be9..039ca63a 100644 --- a/pubnub/test/unit/net/utils.dart +++ b/pubnub/test/unit/net/utils.dart @@ -8,13 +8,16 @@ void main() { expect(isHeaderForbidden('Content-Length'), equals(true)); }); - test('isHeaderForbidden should return true for any Sec- or Proxy- header', () { + test('isHeaderForbidden should return true for any Sec- or Proxy- header', + () { expect(isHeaderForbidden('Sec-Test-1'), equals(true)); expect(isHeaderForbidden('Sec-Random-2'), equals(true)); expect(isHeaderForbidden('Proxy-Whatever'), equals(true)); }); - test('isHeaderForbidden should return false for any other header not specified', () { + test( + 'isHeaderForbidden should return false for any other header not specified', + () { expect(isHeaderForbidden('X-Custom-Header'), equals(false)); expect(isHeaderForbidden('Content-Type'), equals(false)); }); From b0e7a01bba702974087b1cc3e5f05518de09406d Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Wed, 17 May 2023 11:34:22 +0530 Subject: [PATCH 03/12] fix: upgrade dart version --- acceptance_tests/pubspec.yaml | 2 +- pubnub/pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/acceptance_tests/pubspec.yaml b/acceptance_tests/pubspec.yaml index 13758068..fdb35621 100644 --- a/acceptance_tests/pubspec.yaml +++ b/acceptance_tests/pubspec.yaml @@ -5,7 +5,7 @@ version: 1.0.0 publish_to: none environment: - sdk: ">=2.17.0 <3.0.0" + sdk: ">=3.0.0 <4.0.0" dependencies: glob: ^2.0.1 diff --git a/pubnub/pubspec.yaml b/pubnub/pubspec.yaml index 1df49b14..0aa976f4 100644 --- a/pubnub/pubspec.yaml +++ b/pubnub/pubspec.yaml @@ -4,7 +4,7 @@ version: 4.2.2 homepage: https://www.pubnub.com/docs/sdks/dart environment: - sdk: ">=2.17.0 <3.0.0" + sdk: ">=3.0.0 <4.0.0" scripts: test: From 9245369a65f61dd40dc8aa748f8d160aee1593fe Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Wed, 17 May 2023 11:42:25 +0530 Subject: [PATCH 04/12] derry --- .github/workflows/run-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 7640510b..c5e56a3c 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -51,7 +51,7 @@ jobs: git clone https://github.com/flutter/flutter.git -b stable "$FLUTTER_PATH" export PATH="$PATH:$FLUTTER_PATH/bin" fi - dart pub global activate derry 1.3.0 + dart pub global activate derry 1.5.0 cd "${{ github.workspace }}/${{ matrix.pkg }}" [[ ${{ matrix.pkg }} == "pubnub_flutter" ]] && flutter pub get || dart pub get derry validate analysis From d57c07a05a9276d2bee2a3e3cd8fddf17f401d3e Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Wed, 17 May 2023 11:48:32 +0530 Subject: [PATCH 05/12] fix: warnings? --- acceptance_tests/lib/src/parameters/keyset.dart | 1 + .../lib/src/steps/pam_v3/step_then_an_auth_error.dart | 1 - .../pam_v3/step_then_error_detail_message_is_not_empty.dart | 1 - .../lib/src/steps/pam_v3/step_then_error_is_returned.dart | 1 - .../pam_v3/step_when_i_attempt_publish_with_authToken.dart | 1 - .../src/steps/step_then_i_receive_successful_response.dart | 1 - .../lib/src/steps/step_when_i_request_current_time.dart | 1 - .../lib/src/steps/step_when_i_send_a_signal.dart | 1 - acceptance_tests/lib/src/steps/step_when_i_subscribe.dart | 1 - pubnub/lib/src/core/net/exceptions.dart | 6 +++--- pubnub/lib/src/core/supervisor/signals.dart | 1 - .../lib/src/dx/_endpoints/objects/membership_metadata.dart | 6 +++--- pubnub/lib/src/dx/_endpoints/objects/uuid_metadata.dart | 2 +- pubnub/lib/src/dx/files/files.dart | 6 +++--- pubnub/lib/src/dx/objects/channel_metadata.dart | 2 -- pubnub/lib/src/dx/objects/schema.dart | 4 ++-- pubnub/lib/src/dx/objects/uuid_metadata.dart | 2 -- pubnub/lib/src/networking/meta/diagnostics/html.dart | 1 + pubnub/lib/src/networking/meta/diagnostics/io.dart | 1 + pubnub/lib/src/parser/parser.dart | 1 - pubnub/lib/src/subscribe/envelope.dart | 3 +-- pubnub/test/integration/subscribe/subscribe_test.dart | 1 - pubnub/test/unit/dx/channel_test.dart | 3 --- pubnub/test/unit/dx/file_test.dart | 1 - pubnub/test/unit/dx/message_action_test.dart | 2 -- pubnub/test/unit/dx/publish_test.dart | 2 -- pubnub/test/unit/dx/push_test.dart | 3 --- 27 files changed, 16 insertions(+), 40 deletions(-) diff --git a/acceptance_tests/lib/src/parameters/keyset.dart b/acceptance_tests/lib/src/parameters/keyset.dart index cbb2bd39..eda159de 100644 --- a/acceptance_tests/lib/src/parameters/keyset.dart +++ b/acceptance_tests/lib/src/parameters/keyset.dart @@ -35,5 +35,6 @@ class KeysetParameter extends CustomParameter { cipherKey: CipherKey.fromUtf8('invalid'), ); } + return null; }); } diff --git a/acceptance_tests/lib/src/steps/pam_v3/step_then_an_auth_error.dart b/acceptance_tests/lib/src/steps/pam_v3/step_then_an_auth_error.dart index cbebcfe8..c0d19feb 100644 --- a/acceptance_tests/lib/src/steps/pam_v3/step_then_an_auth_error.dart +++ b/acceptance_tests/lib/src/steps/pam_v3/step_then_an_auth_error.dart @@ -1,7 +1,6 @@ // import 'package:gherkin/gherkin.dart'; import 'package:pubnub/core.dart'; -import 'package:pubnub/pubnub.dart'; import 'package:test/test.dart'; import '../../world.dart'; diff --git a/acceptance_tests/lib/src/steps/pam_v3/step_then_error_detail_message_is_not_empty.dart b/acceptance_tests/lib/src/steps/pam_v3/step_then_error_detail_message_is_not_empty.dart index f196c2f1..d3d252e8 100644 --- a/acceptance_tests/lib/src/steps/pam_v3/step_then_error_detail_message_is_not_empty.dart +++ b/acceptance_tests/lib/src/steps/pam_v3/step_then_error_detail_message_is_not_empty.dart @@ -1,5 +1,4 @@ import 'package:gherkin/gherkin.dart'; -import 'package:pubnub/pubnub.dart'; import 'package:test/test.dart'; import '../../world.dart'; diff --git a/acceptance_tests/lib/src/steps/pam_v3/step_then_error_is_returned.dart b/acceptance_tests/lib/src/steps/pam_v3/step_then_error_is_returned.dart index f3e9674b..c0286a46 100644 --- a/acceptance_tests/lib/src/steps/pam_v3/step_then_error_is_returned.dart +++ b/acceptance_tests/lib/src/steps/pam_v3/step_then_error_is_returned.dart @@ -1,5 +1,4 @@ import 'package:gherkin/gherkin.dart'; -import 'package:pubnub/pubnub.dart'; import 'package:test/test.dart'; import '../../world.dart'; diff --git a/acceptance_tests/lib/src/steps/pam_v3/step_when_i_attempt_publish_with_authToken.dart b/acceptance_tests/lib/src/steps/pam_v3/step_when_i_attempt_publish_with_authToken.dart index bc181225..a341570e 100644 --- a/acceptance_tests/lib/src/steps/pam_v3/step_when_i_attempt_publish_with_authToken.dart +++ b/acceptance_tests/lib/src/steps/pam_v3/step_when_i_attempt_publish_with_authToken.dart @@ -1,6 +1,5 @@ import 'package:gherkin/gherkin.dart'; import 'package:pubnub/core.dart'; -import 'package:pubnub/pubnub.dart'; import 'package:test/expect.dart'; import '../../world.dart'; diff --git a/acceptance_tests/lib/src/steps/step_then_i_receive_successful_response.dart b/acceptance_tests/lib/src/steps/step_then_i_receive_successful_response.dart index 0a8405f5..2382a9be 100644 --- a/acceptance_tests/lib/src/steps/step_then_i_receive_successful_response.dart +++ b/acceptance_tests/lib/src/steps/step_then_i_receive_successful_response.dart @@ -1,4 +1,3 @@ -import 'dart:io'; import 'package:gherkin/gherkin.dart'; import 'package:pubnub/pubnub.dart'; diff --git a/acceptance_tests/lib/src/steps/step_when_i_request_current_time.dart b/acceptance_tests/lib/src/steps/step_when_i_request_current_time.dart index 56084e61..e7eea3d1 100644 --- a/acceptance_tests/lib/src/steps/step_when_i_request_current_time.dart +++ b/acceptance_tests/lib/src/steps/step_when_i_request_current_time.dart @@ -1,5 +1,4 @@ import 'package:gherkin/gherkin.dart'; -import 'package:pubnub/pubnub.dart'; import '../world.dart'; diff --git a/acceptance_tests/lib/src/steps/step_when_i_send_a_signal.dart b/acceptance_tests/lib/src/steps/step_when_i_send_a_signal.dart index 8c17a608..3ae01953 100644 --- a/acceptance_tests/lib/src/steps/step_when_i_send_a_signal.dart +++ b/acceptance_tests/lib/src/steps/step_when_i_send_a_signal.dart @@ -1,5 +1,4 @@ import 'package:gherkin/gherkin.dart'; -import 'package:pubnub/pubnub.dart'; import '../world.dart'; diff --git a/acceptance_tests/lib/src/steps/step_when_i_subscribe.dart b/acceptance_tests/lib/src/steps/step_when_i_subscribe.dart index 26ec0447..a658f954 100644 --- a/acceptance_tests/lib/src/steps/step_when_i_subscribe.dart +++ b/acceptance_tests/lib/src/steps/step_when_i_subscribe.dart @@ -1,4 +1,3 @@ -import 'dart:convert'; import 'package:gherkin/gherkin.dart'; diff --git a/pubnub/lib/src/core/net/exceptions.dart b/pubnub/lib/src/core/net/exceptions.dart index c5911df3..bfd82a22 100644 --- a/pubnub/lib/src/core/net/exceptions.dart +++ b/pubnub/lib/src/core/net/exceptions.dart @@ -2,19 +2,19 @@ import '../exceptions.dart'; import 'response.dart'; class RequestTimeoutException extends PubNubException { - final dynamic? additionalData; + final dynamic additionalData; RequestTimeoutException([this.additionalData]) : super('request timed out'); } class RequestCancelException extends PubNubException { - final dynamic? additionalData; + final dynamic additionalData; RequestCancelException([this.additionalData]) : super('request cancelled'); } class RequestOtherException extends PubNubException { - final dynamic? additionalData; + final dynamic additionalData; RequestOtherException([this.additionalData]) : super('request failed ($additionalData)'); diff --git a/pubnub/lib/src/core/supervisor/signals.dart b/pubnub/lib/src/core/supervisor/signals.dart index 6e6a3702..de9aab92 100644 --- a/pubnub/lib/src/core/supervisor/signals.dart +++ b/pubnub/lib/src/core/supervisor/signals.dart @@ -1,7 +1,6 @@ import 'dart:async'; import 'package:pubnub/core.dart'; -import 'event.dart'; final _logger = injectLogger('pubnub.core.supervisor.signals'); diff --git a/pubnub/lib/src/dx/_endpoints/objects/membership_metadata.dart b/pubnub/lib/src/dx/_endpoints/objects/membership_metadata.dart index 1c8b8211..4e300f81 100644 --- a/pubnub/lib/src/dx/_endpoints/objects/membership_metadata.dart +++ b/pubnub/lib/src/dx/_endpoints/objects/membership_metadata.dart @@ -59,7 +59,7 @@ class GetMembershipsMetadataParams extends Parameters { /// {@category Objects} class MembershipMetadata { ChannelMetadataDetails _channel; - dynamic? _custom; + dynamic _custom; String _updated; String _eTag; @@ -212,12 +212,12 @@ class GetChannelMembersParams extends Parameters { /// {@category Objects} class ChannelMemberMetadata { final UuidMetadataDetails _uuid; - final dynamic? _custom; + final dynamic _custom; final String _updated; final String _eTag; UuidMetadataDetails get uuid => _uuid; - dynamic? get custom => _custom; + dynamic get custom => _custom; String get updated => _updated; String get eTag => _eTag; diff --git a/pubnub/lib/src/dx/_endpoints/objects/uuid_metadata.dart b/pubnub/lib/src/dx/_endpoints/objects/uuid_metadata.dart index f39e5473..f814afe0 100644 --- a/pubnub/lib/src/dx/_endpoints/objects/uuid_metadata.dart +++ b/pubnub/lib/src/dx/_endpoints/objects/uuid_metadata.dart @@ -56,7 +56,7 @@ class UuidMetadataDetails { String? get externalId => _externalId; String? get profileUrl => _profileUrl; String? get email => _email; - dynamic? get custom => _custom; + dynamic get custom => _custom; String? get updated => _updated; String? get eTag => _eTag; diff --git a/pubnub/lib/src/dx/files/files.dart b/pubnub/lib/src/dx/files/files.dart index e791547e..5a9f7310 100644 --- a/pubnub/lib/src/dx/files/files.dart +++ b/pubnub/lib/src/dx/files/files.dart @@ -54,10 +54,10 @@ class FileDx { Future sendFile( String channel, String fileName, List file, {CipherKey? cipherKey, - dynamic? fileMessage, + dynamic fileMessage, bool? storeFileMessage, int? fileMessageTtl, - dynamic? fileMessageMeta, + dynamic fileMessageMeta, Keyset? keyset, String? using}) async { keyset ??= _core.keysets[using]; @@ -148,7 +148,7 @@ class FileDx { String channel, FileMessage message, {bool? storeMessage, int? ttl, - dynamic? meta, + dynamic meta, CipherKey? cipherKey, Keyset? keyset, String? using}) async { diff --git a/pubnub/lib/src/dx/objects/channel_metadata.dart b/pubnub/lib/src/dx/objects/channel_metadata.dart index 1d17de6e..a3ac63db 100644 --- a/pubnub/lib/src/dx/objects/channel_metadata.dart +++ b/pubnub/lib/src/dx/objects/channel_metadata.dart @@ -1,7 +1,5 @@ import 'package:pubnub/core.dart'; -import '../_endpoints/objects/objects_types.dart'; import 'objects.dart'; -import 'objects_types.dart'; /// Represents a channel metadata. /// diff --git a/pubnub/lib/src/dx/objects/schema.dart b/pubnub/lib/src/dx/objects/schema.dart index 5d7a6ec3..b63fc105 100644 --- a/pubnub/lib/src/dx/objects/schema.dart +++ b/pubnub/lib/src/dx/objects/schema.dart @@ -4,7 +4,7 @@ class UuidMetadataInput { String? name; String? email; - dynamic? custom; + dynamic custom; String? externalId; String? profileUrl; @@ -26,7 +26,7 @@ class UuidMetadataInput { class ChannelMetadataInput { String? name; String? description; - dynamic? custom; + dynamic custom; ChannelMetadataInput({this.name, this.description, this.custom}); diff --git a/pubnub/lib/src/dx/objects/uuid_metadata.dart b/pubnub/lib/src/dx/objects/uuid_metadata.dart index d978295d..27c9d4ed 100644 --- a/pubnub/lib/src/dx/objects/uuid_metadata.dart +++ b/pubnub/lib/src/dx/objects/uuid_metadata.dart @@ -1,7 +1,5 @@ import 'package:pubnub/core.dart'; -import '../_endpoints/objects/objects_types.dart'; import 'objects.dart'; -import 'schema.dart'; /// Representation of UuidMetadata object /// Useful while dealing with one specific `uuid` details diff --git a/pubnub/lib/src/networking/meta/diagnostics/html.dart b/pubnub/lib/src/networking/meta/diagnostics/html.dart index 997bf86c..9d03e704 100644 --- a/pubnub/lib/src/networking/meta/diagnostics/html.dart +++ b/pubnub/lib/src/networking/meta/diagnostics/html.dart @@ -42,4 +42,5 @@ Diagnostic? getNetworkDiagnostic(dynamic exception) { return AccessDeniedDiagnostic(); } } + return null; } diff --git a/pubnub/lib/src/networking/meta/diagnostics/io.dart b/pubnub/lib/src/networking/meta/diagnostics/io.dart index 24b1f4c7..d96c6c87 100644 --- a/pubnub/lib/src/networking/meta/diagnostics/io.dart +++ b/pubnub/lib/src/networking/meta/diagnostics/io.dart @@ -70,6 +70,7 @@ Diagnostic? getNetworkDiagnostic(dynamic exception) { return AccessDeniedDiagnostic(); } } + return null; } enum _Errno { diff --git a/pubnub/lib/src/parser/parser.dart b/pubnub/lib/src/parser/parser.dart index 3f38a111..97a8164f 100644 --- a/pubnub/lib/src/parser/parser.dart +++ b/pubnub/lib/src/parser/parser.dart @@ -3,7 +3,6 @@ import 'package:xml/xml.dart' show XmlDocument; import 'package:pubnub/core.dart'; -import '../core/parser.dart'; /// @nodoc abstract class Parser { diff --git a/pubnub/lib/src/subscribe/envelope.dart b/pubnub/lib/src/subscribe/envelope.dart index ca10ef72..66ef626c 100644 --- a/pubnub/lib/src/subscribe/envelope.dart +++ b/pubnub/lib/src/subscribe/envelope.dart @@ -1,5 +1,4 @@ import 'package:pubnub/core.dart'; -import 'package:pubnub/pubnub.dart'; /// Represents a message received from a subscription. /// @@ -17,7 +16,7 @@ class Envelope extends BaseMessage { final Timetoken? originalTimetoken; final int? originalRegion; - final dynamic? userMeta; + final dynamic userMeta; dynamic get payload => content; diff --git a/pubnub/test/integration/subscribe/subscribe_test.dart b/pubnub/test/integration/subscribe/subscribe_test.dart index e7ebc298..fe22283b 100644 --- a/pubnub/test/integration/subscribe/subscribe_test.dart +++ b/pubnub/test/integration/subscribe/subscribe_test.dart @@ -5,7 +5,6 @@ import 'dart:io'; import 'package:test/test.dart'; import 'package:pubnub/pubnub.dart'; -import 'package:pubnub/core.dart'; import '_utils.dart'; diff --git a/pubnub/test/unit/dx/channel_test.dart b/pubnub/test/unit/dx/channel_test.dart index 68be6655..4d52abac 100644 --- a/pubnub/test/unit/dx/channel_test.dart +++ b/pubnub/test/unit/dx/channel_test.dart @@ -1,10 +1,7 @@ import 'package:test/test.dart'; import 'package:pubnub/pubnub.dart'; -import 'package:pubnub/core.dart'; -import 'package:pubnub/src/dx/channel/channel.dart'; -import 'package:pubnub/src/dx/channel/channel_history.dart'; import '../net/fake_net.dart'; part './fixtures/channel.dart'; diff --git a/pubnub/test/unit/dx/file_test.dart b/pubnub/test/unit/dx/file_test.dart index 8ba8c09f..6523cf3d 100644 --- a/pubnub/test/unit/dx/file_test.dart +++ b/pubnub/test/unit/dx/file_test.dart @@ -3,7 +3,6 @@ import 'package:pubnub/crypto.dart'; import 'package:test/test.dart'; import 'package:pubnub/pubnub.dart'; -import 'package:pubnub/core.dart'; import '../net/fake_net.dart'; part 'fixtures/files.dart'; diff --git a/pubnub/test/unit/dx/message_action_test.dart b/pubnub/test/unit/dx/message_action_test.dart index 59eb524b..b18d3ec6 100644 --- a/pubnub/test/unit/dx/message_action_test.dart +++ b/pubnub/test/unit/dx/message_action_test.dart @@ -1,9 +1,7 @@ import 'package:test/test.dart'; import 'package:pubnub/pubnub.dart'; -import 'package:pubnub/core.dart'; -import 'package:pubnub/src/dx/_utils/utils.dart'; import '../net/fake_net.dart'; diff --git a/pubnub/test/unit/dx/publish_test.dart b/pubnub/test/unit/dx/publish_test.dart index 968d16af..4d2df118 100644 --- a/pubnub/test/unit/dx/publish_test.dart +++ b/pubnub/test/unit/dx/publish_test.dart @@ -1,8 +1,6 @@ import 'package:test/test.dart'; import 'package:pubnub/pubnub.dart'; -import 'package:pubnub/core.dart'; -import 'package:pubnub/src/dx/_utils/utils.dart'; import '../net/fake_net.dart'; part './fixtures/publish.dart'; diff --git a/pubnub/test/unit/dx/push_test.dart b/pubnub/test/unit/dx/push_test.dart index 35ae0989..c090ac18 100644 --- a/pubnub/test/unit/dx/push_test.dart +++ b/pubnub/test/unit/dx/push_test.dart @@ -1,9 +1,6 @@ import 'package:test/test.dart'; import 'package:pubnub/pubnub.dart'; -import 'package:pubnub/core.dart'; -import 'package:pubnub/src/dx/_endpoints/push.dart'; -import 'package:pubnub/src/dx/_utils/utils.dart'; import '../net/fake_net.dart'; part './fixtures/push.dart'; From 6d08a3e653b380d1d01c8567335681c5af8422f7 Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Wed, 17 May 2023 11:52:34 +0530 Subject: [PATCH 06/12] fix: one more analyze? --- pubnub/lib/src/dx/_utils/exceptions.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubnub/lib/src/dx/_utils/exceptions.dart b/pubnub/lib/src/dx/_utils/exceptions.dart index 602b53af..073eabdf 100644 --- a/pubnub/lib/src/dx/_utils/exceptions.dart +++ b/pubnub/lib/src/dx/_utils/exceptions.dart @@ -8,7 +8,7 @@ PubNubException getExceptionFromAny(dynamic error) { } if (error is XmlDocument) { - var details = error.rootElement.getElement('Message')?.text; + var details = error.rootElement.getElement('Message')?.value; return PubNubException( 'Request to third party service failed. Details: $details'); From 6957cb9bd15ab197d3f0233264a7d755e2b3cd30 Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Thu, 18 May 2023 08:06:19 +0530 Subject: [PATCH 07/12] fix: test --- pubnub/lib/src/dx/_endpoints/history.dart | 6 +++--- pubnub/lib/src/dx/time.dart | 2 +- pubnub/lib/src/subscribe/envelope.dart | 4 ++-- pubnub/pubspec.yaml | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pubnub/lib/src/dx/_endpoints/history.dart b/pubnub/lib/src/dx/_endpoints/history.dart index de3747c8..353fb7a6 100644 --- a/pubnub/lib/src/dx/_endpoints/history.dart +++ b/pubnub/lib/src/dx/_endpoints/history.dart @@ -63,8 +63,8 @@ class FetchHistoryResult extends Result { factory FetchHistoryResult.fromJson(dynamic object) { if (object is List) { - return FetchHistoryResult._(object[0], Timetoken(BigInt.parse(object[1])), - Timetoken(BigInt.parse(object[2]))); + return FetchHistoryResult._(object[0], Timetoken(BigInt.parse('${object[1]}')), + Timetoken(BigInt.parse('${object[2]}'))); } throw getExceptionFromAny(object); @@ -159,7 +159,7 @@ class BatchHistoryResultEntry { cipherKey == null ? object['message'] : decryptFunction!(cipherKey, object['message']), - Timetoken(BigInt.parse(object['timetoken'])), + Timetoken(BigInt.parse('${object['timetoken']}')), object['uuid'], MessageTypeExtension.fromInt(object['message_type']), object['actions'], diff --git a/pubnub/lib/src/dx/time.dart b/pubnub/lib/src/dx/time.dart index 57c00eb4..1b50d83b 100644 --- a/pubnub/lib/src/dx/time.dart +++ b/pubnub/lib/src/dx/time.dart @@ -9,6 +9,6 @@ mixin TimeDx on Core { return defaultFlow( core: this, params: TimeParams(), - serialize: (object, [_]) => Timetoken(BigInt.parse(object[0]))); + serialize: (object, [_]) => Timetoken(BigInt.parse('${object[0]}'))); } } diff --git a/pubnub/lib/src/subscribe/envelope.dart b/pubnub/lib/src/subscribe/envelope.dart index 66ef626c..738d7ed3 100644 --- a/pubnub/lib/src/subscribe/envelope.dart +++ b/pubnub/lib/src/subscribe/envelope.dart @@ -52,10 +52,10 @@ class Envelope extends BaseMessage { flags: object['f'] as int, uuid: UUID(object['i'] ?? ''), originalTimetoken: object['o'] != null - ? Timetoken(BigInt.parse(object['o']['t'])) + ? Timetoken(BigInt.parse('${object['o']['t']}')) : null, originalRegion: object['o']?['r'], - publishedAt: Timetoken(BigInt.parse(object['p']['t'])), + publishedAt: Timetoken(BigInt.parse('${object['p']['t']}')), region: object['p']['r'], userMeta: object['u'], ); diff --git a/pubnub/pubspec.yaml b/pubnub/pubspec.yaml index 0aa976f4..122cfc31 100644 --- a/pubnub/pubspec.yaml +++ b/pubnub/pubspec.yaml @@ -26,4 +26,4 @@ dependencies: pool: ^1.5.0 xml: ^6.1.0 dev_dependencies: - test: 1.16.7 + test: ^1.24.3 From c69614d56b2ca3ebac2360fcf4a5f1939b46b943 Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Thu, 18 May 2023 10:11:41 +0530 Subject: [PATCH 08/12] take-1: test only pubnub --- .github/workflows/run-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index c5e56a3c..ff1f1611 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -19,7 +19,7 @@ jobs: strategy: fail-fast: true matrix: - pkg: [pubnub, pubnub_flutter] + pkg: [pubnub] steps: - name: Checkout repository uses: actions/checkout@v3 From eb515013a28a188bb9eabc3280f6348aefe02676 Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Thu, 18 May 2023 11:17:14 +0530 Subject: [PATCH 09/12] take-2 upgrade dart setup version --- .github/workflows/run-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index ff1f1611..de461b9c 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -40,7 +40,7 @@ jobs: restore-keys: | ${{ runner.os }}-${{ matrix.pkg }}- - name: Setup Dart stable - uses: dart-lang/setup-dart@v1.3 + uses: dart-lang/setup-dart@v1.5.0 - name: "Build and run tests for '${{ matrix.pkg }}'" env: PKG: ${{ matrix.pkg }} From 4375c32604714996a56708b0cf242a8f4d4b2125 Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Thu, 18 May 2023 11:22:56 +0530 Subject: [PATCH 10/12] take-3: may be deprecated command ? --- pubnub/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubnub/pubspec.yaml b/pubnub/pubspec.yaml index 122cfc31..5c54b692 100644 --- a/pubnub/pubspec.yaml +++ b/pubnub/pubspec.yaml @@ -8,7 +8,7 @@ environment: scripts: test: - default: dart pub run test -P unit + default: dart run test -P unit integration: dart pub run test -P integration validate: analysis: dart analyze --fatal-warnings lib From 61bcfbec1b0867531c6c289fe7c1170b40ab45d1 Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Thu, 18 May 2023 11:37:42 +0530 Subject: [PATCH 11/12] dart format --- pubnub/lib/src/dx/_endpoints/history.dart | 4 +++- pubnub/lib/src/parser/parser.dart | 1 - pubnub/test/unit/dx/channel_test.dart | 1 - pubnub/test/unit/dx/message_action_test.dart | 1 - 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/pubnub/lib/src/dx/_endpoints/history.dart b/pubnub/lib/src/dx/_endpoints/history.dart index 353fb7a6..0c244bae 100644 --- a/pubnub/lib/src/dx/_endpoints/history.dart +++ b/pubnub/lib/src/dx/_endpoints/history.dart @@ -63,7 +63,9 @@ class FetchHistoryResult extends Result { factory FetchHistoryResult.fromJson(dynamic object) { if (object is List) { - return FetchHistoryResult._(object[0], Timetoken(BigInt.parse('${object[1]}')), + return FetchHistoryResult._( + object[0], + Timetoken(BigInt.parse('${object[1]}')), Timetoken(BigInt.parse('${object[2]}'))); } diff --git a/pubnub/lib/src/parser/parser.dart b/pubnub/lib/src/parser/parser.dart index 97a8164f..518b172a 100644 --- a/pubnub/lib/src/parser/parser.dart +++ b/pubnub/lib/src/parser/parser.dart @@ -3,7 +3,6 @@ import 'package:xml/xml.dart' show XmlDocument; import 'package:pubnub/core.dart'; - /// @nodoc abstract class Parser { Future decode(String input); diff --git a/pubnub/test/unit/dx/channel_test.dart b/pubnub/test/unit/dx/channel_test.dart index 4d52abac..845c6343 100644 --- a/pubnub/test/unit/dx/channel_test.dart +++ b/pubnub/test/unit/dx/channel_test.dart @@ -2,7 +2,6 @@ import 'package:test/test.dart'; import 'package:pubnub/pubnub.dart'; - import '../net/fake_net.dart'; part './fixtures/channel.dart'; diff --git a/pubnub/test/unit/dx/message_action_test.dart b/pubnub/test/unit/dx/message_action_test.dart index b18d3ec6..0e26a9c2 100644 --- a/pubnub/test/unit/dx/message_action_test.dart +++ b/pubnub/test/unit/dx/message_action_test.dart @@ -2,7 +2,6 @@ import 'package:test/test.dart'; import 'package:pubnub/pubnub.dart'; - import '../net/fake_net.dart'; void main() { From 02b5333c192aae18a7bf3af250f441a165513f6f Mon Sep 17 00:00:00 2001 From: PubNub Release Bot <120067856+pubnub-release-bot@users.noreply.github.com> Date: Thu, 18 May 2023 06:22:12 +0000 Subject: [PATCH 12/12] PubNub SDK v4.2.3 release. --- .pubnub.yml | 7 ++++++- pubnub/CHANGELOG.md | 6 ++++++ pubnub/README.md | 2 +- pubnub/lib/src/core/core.dart | 2 +- pubnub/pubspec.yaml | 2 +- 5 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.pubnub.yml b/.pubnub.yml index d9d61db9..2d01df2c 100644 --- a/.pubnub.yml +++ b/.pubnub.yml @@ -1,5 +1,10 @@ --- changelog: + - date: 2023-05-18 + version: v4.2.3 + changes: + - type: bug + text: "Fixes issue of losing timetoken value precision in web environment." - date: 2022-11-14 version: v4.2.2 changes: @@ -415,7 +420,7 @@ supported-platforms: platforms: - "Dart SDK >=2.6.0 <3.0.0" version: "PubNub Dart SDK" -version: "4.2.2" +version: "4.2.3" sdks: - full-name: PubNub Dart SDK diff --git a/pubnub/CHANGELOG.md b/pubnub/CHANGELOG.md index 69630e83..afd9be1e 100644 --- a/pubnub/CHANGELOG.md +++ b/pubnub/CHANGELOG.md @@ -1,3 +1,9 @@ +## v4.2.3 +May 18 2023 + +#### Fixed +- Fixes issue of losing timetoken value precision in web environment. Fixed the following issues reported by [@RicharC293](https://github.com/RicharC293): [#110](https://github.com/pubnub/dart/issues/110). + ## v4.2.2 November 14 2022 diff --git a/pubnub/README.md b/pubnub/README.md index 647a5964..54c4585a 100644 --- a/pubnub/README.md +++ b/pubnub/README.md @@ -14,7 +14,7 @@ To add the package to your Dart or Flutter project, add `pubnub` as a dependency ```yaml dependencies: - pubnub: ^4.2.2 + pubnub: ^4.2.3 ``` After adding the dependency to `pubspec.yaml`, run the `dart pub get` command in the root directory of your project (the same that the `pubspec.yaml` is in). diff --git a/pubnub/lib/src/core/core.dart b/pubnub/lib/src/core/core.dart index 377bb99d..c0d0f75b 100644 --- a/pubnub/lib/src/core/core.dart +++ b/pubnub/lib/src/core/core.dart @@ -21,7 +21,7 @@ class Core { /// Internal module responsible for supervising. SupervisorModule supervisor = SupervisorModule(); - static String version = '4.2.2'; + static String version = '4.2.3'; Core( {Keyset? defaultKeyset, diff --git a/pubnub/pubspec.yaml b/pubnub/pubspec.yaml index 5c54b692..f7d7bd41 100644 --- a/pubnub/pubspec.yaml +++ b/pubnub/pubspec.yaml @@ -1,6 +1,6 @@ name: pubnub description: PubNub SDK v5 for Dart lang (with Flutter support) that allows you to create real-time applications -version: 4.2.2 +version: 4.2.3 homepage: https://www.pubnub.com/docs/sdks/dart environment: