fix: Update the generated enum files

This commit is contained in:
Nicolas Werner 2023-04-17 16:54:43 +02:00
parent ab0403657d
commit b95edec462
No known key found for this signature in database
3 changed files with 104 additions and 42 deletions

View File

@ -1,3 +1,10 @@
## [1.6.1] - 17th Apr 2023
Fixes a small issue in the last release, where some enhanced enums were not
updated and as such missing a few members.
- fix: Update the generated enum files
## [1.6.0] - 17th Apr 2023 ## [1.6.0] - 17th Apr 2023
This release updates to version 1.6 of the Matrix specification. Users might This release updates to version 1.6 of the Matrix specification. Users might

View File

@ -6,6 +6,88 @@ part of 'model.dart';
// EnhancedEnumGenerator // EnhancedEnumGenerator
// ************************************************************************** // **************************************************************************
extension DirectionFromStringExtension on Iterable<Direction> {
Direction? fromString(String val) {
final override = {
'b': Direction.b,
'f': Direction.f,
}[val];
// ignore: unnecessary_this
return this.contains(override) ? override : null;
}
}
extension DirectionEnhancedEnum on Direction {
@override
// ignore: override_on_non_overriding_member
String get name => {
Direction.b: 'b',
Direction.f: 'f',
}[this]!;
bool get isB => this == Direction.b;
bool get isF => this == Direction.f;
T when<T>({
required T Function() b,
required T Function() f,
}) =>
{
Direction.b: b,
Direction.f: f,
}[this]!();
T maybeWhen<T>({
T? Function()? b,
T? Function()? f,
required T Function() orElse,
}) =>
{
Direction.b: b,
Direction.f: f,
}[this]
?.call() ??
orElse();
}
extension IncludeFromStringExtension on Iterable<Include> {
Include? fromString(String val) {
final override = {
'all': Include.all,
'participated': Include.participated,
}[val];
// ignore: unnecessary_this
return this.contains(override) ? override : null;
}
}
extension IncludeEnhancedEnum on Include {
@override
// ignore: override_on_non_overriding_member
String get name => {
Include.all: 'all',
Include.participated: 'participated',
}[this]!;
bool get isAll => this == Include.all;
bool get isParticipated => this == Include.participated;
T when<T>({
required T Function() all,
required T Function() participated,
}) =>
{
Include.all: all,
Include.participated: participated,
}[this]!();
T maybeWhen<T>({
T? Function()? all,
T? Function()? participated,
required T Function() orElse,
}) =>
{
Include.all: all,
Include.participated: participated,
}[this]
?.call() ??
orElse();
}
extension ThirdPartyIdentifierMediumFromStringExtension extension ThirdPartyIdentifierMediumFromStringExtension
on Iterable<ThirdPartyIdentifierMedium> { on Iterable<ThirdPartyIdentifierMedium> {
ThirdPartyIdentifierMedium? fromString(String val) { ThirdPartyIdentifierMedium? fromString(String val) {
@ -514,51 +596,12 @@ extension MembershipEnhancedEnum on Membership {
orElse(); orElse();
} }
extension DirectionFromStringExtension on Iterable<Direction> {
Direction? fromString(String val) {
final override = {
'b': Direction.b,
'f': Direction.f,
}[val];
// ignore: unnecessary_this
return this.contains(override) ? override : null;
}
}
extension DirectionEnhancedEnum on Direction {
@override
// ignore: override_on_non_overriding_member
String get name => {
Direction.b: 'b',
Direction.f: 'f',
}[this]!;
bool get isB => this == Direction.b;
bool get isF => this == Direction.f;
T when<T>({
required T Function() b,
required T Function() f,
}) =>
{
Direction.b: b,
Direction.f: f,
}[this]!();
T maybeWhen<T>({
T? Function()? b,
T? Function()? f,
required T Function() orElse,
}) =>
{
Direction.b: b,
Direction.f: f,
}[this]
?.call() ??
orElse();
}
extension ReceiptTypeFromStringExtension on Iterable<ReceiptType> { extension ReceiptTypeFromStringExtension on Iterable<ReceiptType> {
ReceiptType? fromString(String val) { ReceiptType? fromString(String val) {
final override = { final override = {
'm.fully_read': ReceiptType.mFullyRead,
'm.read': ReceiptType.mRead, 'm.read': ReceiptType.mRead,
'm.read.private': ReceiptType.mReadPrivate,
}[val]; }[val];
// ignore: unnecessary_this // ignore: unnecessary_this
return this.contains(override) ? override : null; return this.contains(override) ? override : null;
@ -569,21 +612,33 @@ extension ReceiptTypeEnhancedEnum on ReceiptType {
@override @override
// ignore: override_on_non_overriding_member // ignore: override_on_non_overriding_member
String get name => { String get name => {
ReceiptType.mFullyRead: 'm.fully_read',
ReceiptType.mRead: 'm.read', ReceiptType.mRead: 'm.read',
ReceiptType.mReadPrivate: 'm.read.private',
}[this]!; }[this]!;
bool get isMFullyRead => this == ReceiptType.mFullyRead;
bool get isMRead => this == ReceiptType.mRead; bool get isMRead => this == ReceiptType.mRead;
bool get isMReadPrivate => this == ReceiptType.mReadPrivate;
T when<T>({ T when<T>({
required T Function() mFullyRead,
required T Function() mRead, required T Function() mRead,
required T Function() mReadPrivate,
}) => }) =>
{ {
ReceiptType.mFullyRead: mFullyRead,
ReceiptType.mRead: mRead, ReceiptType.mRead: mRead,
ReceiptType.mReadPrivate: mReadPrivate,
}[this]!(); }[this]!();
T maybeWhen<T>({ T maybeWhen<T>({
T? Function()? mFullyRead,
T? Function()? mRead, T? Function()? mRead,
T? Function()? mReadPrivate,
required T Function() orElse, required T Function() orElse,
}) => }) =>
{ {
ReceiptType.mFullyRead: mFullyRead,
ReceiptType.mRead: mRead, ReceiptType.mRead: mRead,
ReceiptType.mReadPrivate: mReadPrivate,
}[this] }[this]
?.call() ?? ?.call() ??
orElse(); orElse();

View File

@ -1,6 +1,6 @@
name: matrix_api_lite name: matrix_api_lite
description: Dead simple data model for the matrix.org client-server API. description: Dead simple data model for the matrix.org client-server API.
version: 1.6.0 version: 1.6.1
homepage: https://famedly.com homepage: https://famedly.com
repository: https://gitlab.com/famedly/company/frontend/libraries/matrix_api_lite/ repository: https://gitlab.com/famedly/company/frontend/libraries/matrix_api_lite/
issues: https://gitlab.com/famedly/company/frontend/libraries/matrix_api_lite/-/issues issues: https://gitlab.com/famedly/company/frontend/libraries/matrix_api_lite/-/issues