diff --git a/melos.yaml b/melos.yaml index 7a5016ff..baa8761d 100644 --- a/melos.yaml +++ b/melos.yaml @@ -65,29 +65,29 @@ scripts: test:dart: run: melos exec -c 1 --fail-fast -- "flutter test --coverage" description: Run Dart tests for a specific package in this project. - select-package: + packageFilters: flutter: false - dir-exists: test + dirExists: test test:flutter: run: melos exec -c 4 --fail-fast -- "flutter test --coverage" description: Run Flutter tests for a specific package in this project. - select-package: + packageFilters: flutter: true - dir-exists: test + dirExists: test clean:flutter: run: melos exec -c 4 --fail-fast -- "flutter clean" description: Run Flutter clean for a specific package in this project. - select-package: + packageFilters: flutter: true coverage:ignore-file: run: | melos exec -c 5 --fail-fast -- "\$MELOS_ROOT_PATH/.github/workflows/scripts/remove-from-coverage.sh" description: Removes all the ignored files from the coverage report. - select-package: - dir-exists: coverage + packageFilters: + dirExists: coverage docs: run: | diff --git a/packages/stream_chat/lib/src/core/models/attachment.dart b/packages/stream_chat/lib/src/core/models/attachment.dart index 4d9a3b30..c757a174 100644 --- a/packages/stream_chat/lib/src/core/models/attachment.dart +++ b/packages/stream_chat/lib/src/core/models/attachment.dart @@ -146,13 +146,13 @@ class Attachment extends Equatable { /// Shortcut for file size. /// /// {@macro fileSize} - @JsonKey(ignore: true) + @JsonKey(includeToJson: false, includeFromJson: false) int? get fileSize => extraData['file_size'] as int?; /// Shortcut for file mimeType. /// /// {@macro mimeType} - @JsonKey(ignore: true) + @JsonKey(includeToJson: false, includeFromJson: false) String? get mimeType => extraData['mime_type'] as String?; /// Known top level fields. diff --git a/packages/stream_chat/lib/src/core/models/channel_model.dart b/packages/stream_chat/lib/src/core/models/channel_model.dart index 8d01f89d..b3523743 100644 --- a/packages/stream_chat/lib/src/core/models/channel_model.dart +++ b/packages/stream_chat/lib/src/core/models/channel_model.dart @@ -62,19 +62,19 @@ class ChannelModel { final String type; /// The cid of this channel - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final String cid; /// List of user permissions on this channel - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final List? ownCapabilities; /// The channel configuration data - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final ChannelConfig config; /// The user that created this channel - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final User? createdBy; /// True if this channel is frozen @@ -82,23 +82,23 @@ class ChannelModel { final bool frozen; /// The date of the last message - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final DateTime? lastMessageAt; /// The date of channel creation - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final DateTime createdAt; /// The date of the last channel update - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final DateTime updatedAt; /// The date of channel deletion - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final DateTime? deletedAt; /// The count of this channel members - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final int memberCount; /// The number of seconds in a cooldown @@ -106,15 +106,15 @@ class ChannelModel { final int cooldown; /// True if the channel is disabled - @JsonKey(ignore: true) + @JsonKey(includeToJson: false, includeFromJson: false) bool? get disabled => extraData['disabled'] as bool?; /// True if the channel is hidden - @JsonKey(ignore: true) + @JsonKey(includeToJson: false, includeFromJson: false) bool? get hidden => extraData['hidden'] as bool?; /// The date of the last time channel got truncated - @JsonKey(ignore: true) + @JsonKey(includeToJson: false, includeFromJson: false) DateTime? get truncatedAt { final truncatedAt = extraData['truncated_at'] as String?; if (truncatedAt == null) return null; @@ -126,7 +126,7 @@ class ChannelModel { final Map extraData; /// The team the channel belongs to - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final String? team; /// Known top level fields. diff --git a/packages/stream_chat/lib/src/core/models/channel_model.g.dart b/packages/stream_chat/lib/src/core/models/channel_model.g.dart index d86c2941..b1a691e3 100644 --- a/packages/stream_chat/lib/src/core/models/channel_model.g.dart +++ b/packages/stream_chat/lib/src/core/models/channel_model.g.dart @@ -42,17 +42,7 @@ Map _$ChannelModelToJson(ChannelModel instance) => { 'id': instance.id, 'type': instance.type, - 'cid': readonly(instance.cid), - 'own_capabilities': readonly(instance.ownCapabilities), - 'config': readonly(instance.config), - 'created_by': readonly(instance.createdBy), 'frozen': instance.frozen, - 'last_message_at': readonly(instance.lastMessageAt), - 'created_at': readonly(instance.createdAt), - 'updated_at': readonly(instance.updatedAt), - 'deleted_at': readonly(instance.deletedAt), - 'member_count': readonly(instance.memberCount), 'cooldown': instance.cooldown, 'extra_data': instance.extraData, - 'team': readonly(instance.team), }; diff --git a/packages/stream_chat/lib/src/core/models/message.dart b/packages/stream_chat/lib/src/core/models/message.dart index 017bb06f..6f3a5b13 100644 --- a/packages/stream_chat/lib/src/core/models/message.dart +++ b/packages/stream_chat/lib/src/core/models/message.dart @@ -95,14 +95,11 @@ class Message extends Equatable { final String? text; /// The status of a sending message. - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) final MessageSendingStatus status; /// The message type. - @JsonKey( - includeIfNull: false, - toJson: Serializer.readOnly, - ) + @JsonKey(includeToJson: false) final String type; /// The list of attachments, either provided by the user or generated from a @@ -115,19 +112,19 @@ class Message extends Equatable { final List mentionedUsers; /// A map describing the count of number of every reaction. - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final Map? reactionCounts; /// A map describing the count of score of every reaction. - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final Map? reactionScores; /// The latest reactions to the message created by any user. - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final List? latestReactions; /// The reactions added to the message by the current user. - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final List? ownReactions; /// The ID of the parent message, if the message is a thread reply. @@ -143,11 +140,11 @@ class Message extends Equatable { String? get quotedMessageId => _quotedMessageId ?? quotedMessage?.id; /// Reserved field indicating the number of replies for this message. - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final int? replyCount; /// Reserved field indicating the thread participants for this message. - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final List? threadParticipants; /// Check if this message needs to show in the channel. @@ -157,34 +154,31 @@ class Message extends Equatable { final bool silent; /// If true the message is shadowed. - @JsonKey( - includeIfNull: false, - toJson: Serializer.readOnly, - ) + @JsonKey(includeToJson: false) final bool shadowed; /// A used command name. - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final String? command; final DateTime? _createdAt; /// Reserved field indicating when the message was deleted. - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final DateTime? deletedAt; /// Reserved field indicating when the message was created. - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) DateTime get createdAt => _createdAt ?? DateTime.now(); final DateTime? _updatedAt; /// Reserved field indicating when the message was updated last time. - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) DateTime get updatedAt => _updatedAt ?? DateTime.now(); /// User who sent the message. - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final User? user; /// If true the message is pinned. diff --git a/packages/stream_chat/lib/src/core/models/message.g.dart b/packages/stream_chat/lib/src/core/models/message.g.dart index 8023cb79..cbf849cc 100644 --- a/packages/stream_chat/lib/src/core/models/message.g.dart +++ b/packages/stream_chat/lib/src/core/models/message.g.dart @@ -75,26 +75,13 @@ Map _$MessageToJson(Message instance) { final val = { 'id': instance.id, 'text': instance.text, - 'type': readonly(instance.type), 'attachments': instance.attachments.map((e) => e.toJson()).toList(), 'mentioned_users': User.toIds(instance.mentionedUsers), - 'reaction_counts': readonly(instance.reactionCounts), - 'reaction_scores': readonly(instance.reactionScores), - 'latest_reactions': readonly(instance.latestReactions), - 'own_reactions': readonly(instance.ownReactions), 'parent_id': instance.parentId, 'quoted_message': readonly(instance.quotedMessage), 'quoted_message_id': instance.quotedMessageId, - 'reply_count': readonly(instance.replyCount), - 'thread_participants': readonly(instance.threadParticipants), 'show_in_channel': instance.showInChannel, 'silent': instance.silent, - 'shadowed': readonly(instance.shadowed), - 'command': readonly(instance.command), - 'deleted_at': readonly(instance.deletedAt), - 'created_at': readonly(instance.createdAt), - 'updated_at': readonly(instance.updatedAt), - 'user': readonly(instance.user), 'pinned': instance.pinned, 'pinned_at': readonly(instance.pinnedAt), 'pin_expires': instance.pinExpires?.toIso8601String(), diff --git a/packages/stream_chat/lib/src/core/models/reaction.dart b/packages/stream_chat/lib/src/core/models/reaction.dart index f16fb09f..2bc6f52b 100644 --- a/packages/stream_chat/lib/src/core/models/reaction.dart +++ b/packages/stream_chat/lib/src/core/models/reaction.dart @@ -33,18 +33,18 @@ class Reaction { final String type; /// The date of the reaction - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final DateTime createdAt; /// The user that sent the reaction - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final User? user; /// The score of the reaction (ie. number of reactions sent) final int score; /// The userId that sent the reaction - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final String? userId; /// Reaction custom extraData diff --git a/packages/stream_chat/lib/src/core/models/reaction.g.dart b/packages/stream_chat/lib/src/core/models/reaction.g.dart index c669e850..6dcac5e1 100644 --- a/packages/stream_chat/lib/src/core/models/reaction.g.dart +++ b/packages/stream_chat/lib/src/core/models/reaction.g.dart @@ -23,9 +23,6 @@ Reaction _$ReactionFromJson(Map json) => Reaction( Map _$ReactionToJson(Reaction instance) => { 'message_id': instance.messageId, 'type': instance.type, - 'created_at': readonly(instance.createdAt), - 'user': readonly(instance.user), 'score': instance.score, - 'user_id': readonly(instance.userId), 'extra_data': instance.extraData, }; diff --git a/packages/stream_chat/lib/src/core/models/user.dart b/packages/stream_chat/lib/src/core/models/user.dart index 6cce01df..ca60e614 100644 --- a/packages/stream_chat/lib/src/core/models/user.dart +++ b/packages/stream_chat/lib/src/core/models/user.dart @@ -79,7 +79,7 @@ class User extends Equatable { /// Shortcut for user name. /// /// {@macro name} - @JsonKey(ignore: true) + @JsonKey(includeToJson: false, includeFromJson: false) String get name { if (extraData.containsKey('name') && extraData['name'] != null) { final name = extraData['name']! as String; @@ -91,48 +91,39 @@ class User extends Equatable { /// Shortcut for user image. /// /// {@macro image} - @JsonKey(ignore: true) + @JsonKey(includeToJson: false, includeFromJson: false) String? get image => extraData['image'] as String?; /// User role. - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final String? role; /// User teams - @JsonKey( - includeIfNull: false, - toJson: Serializer.readOnly, - ) + @JsonKey(includeToJson: false) final List teams; /// Date of user creation. - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final DateTime createdAt; /// Date of last user update. - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final DateTime updatedAt; /// Date of last user connection. - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final DateTime? lastActive; /// True if user is online. - @JsonKey( - includeIfNull: false, - toJson: Serializer.readOnly, - ) + @JsonKey(includeToJson: false) final bool online; /// True if user is banned from the chat. - @JsonKey( - includeIfNull: false, - toJson: Serializer.readOnly, - ) + @JsonKey(includeToJson: false) final bool banned; /// The date at which the ban will expire. - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final DateTime? banExpires; /// The language this user prefers. diff --git a/packages/stream_chat/lib/src/core/models/user.g.dart b/packages/stream_chat/lib/src/core/models/user.g.dart index 3736cad1..47094ffc 100644 --- a/packages/stream_chat/lib/src/core/models/user.g.dart +++ b/packages/stream_chat/lib/src/core/models/user.g.dart @@ -33,14 +33,6 @@ User _$UserFromJson(Map json) => User( Map _$UserToJson(User instance) { final val = { 'id': instance.id, - 'role': readonly(instance.role), - 'teams': readonly(instance.teams), - 'created_at': readonly(instance.createdAt), - 'updated_at': readonly(instance.updatedAt), - 'last_active': readonly(instance.lastActive), - 'online': readonly(instance.online), - 'banned': readonly(instance.banned), - 'ban_expires': readonly(instance.banExpires), }; void writeNotNull(String key, dynamic value) { diff --git a/packages/stream_chat/test/src/core/http/stream_http_client_test.dart b/packages/stream_chat/test/src/core/http/stream_http_client_test.dart index 6abed8ae..4854b98f 100644 --- a/packages/stream_chat/test/src/core/http/stream_http_client_test.dart +++ b/packages/stream_chat/test/src/core/http/stream_http_client_test.dart @@ -129,7 +129,11 @@ void main() { await client.get('path'); } on StreamChatNetworkError catch (e) { expect(e, isA()); - expect(e.message, "Dio can't establish new connection after closed."); + expect( + e.message, + "The connection errored: Dio can't establish a new connection" + ' after it was closed.', + ); } }); diff --git a/packages/stream_chat_flutter_core/test/stream_channel_test.dart b/packages/stream_chat_flutter_core/test/stream_channel_test.dart index 875b885d..60a199f2 100644 --- a/packages/stream_chat_flutter_core/test/stream_channel_test.dart +++ b/packages/stream_chat_flutter_core/test/stream_channel_test.dart @@ -93,7 +93,7 @@ void main() { const errorMessage = 'Error! Error! Error!'; final error = DioError( type: DioErrorType.badResponse, - error: errorMessage, + message: errorMessage, requestOptions: RequestOptions(path: ''), ); when(() => mockChannel.initialized)