From 6deff8f952d259bb369020885528dbddf0b2c96b Mon Sep 17 00:00:00 2001 From: CodeDoctorDE Date: Mon, 23 Dec 2024 20:12:53 +0100 Subject: [PATCH] Convert api to dart_mappable --- api/lib/converters/ical.dart | 2 +- api/lib/helpers/converter.dart | 33 - api/lib/helpers/mapper.dart | 19 + api/lib/helpers/setup.dart | 6 + api/lib/models/cached.dart | 31 +- api/lib/models/event/item/model.dart | 169 +- api/lib/models/event/item/model.freezed.dart | 1857 ------------------ api/lib/models/event/item/model.g.dart | 185 -- api/lib/models/event/item/model.mapper.dart | 898 +++++++++ api/lib/models/event/model.dart | 59 +- api/lib/models/event/model.freezed.dart | 354 ---- api/lib/models/event/model.g.dart | 52 - api/lib/models/event/model.mapper.dart | 282 +++ api/lib/models/extra.dart | 26 +- api/lib/models/extra.freezed.dart | 272 --- api/lib/models/extra.g.dart | 21 - api/lib/models/extra.mapper.dart | 174 ++ api/lib/models/group/model.dart | 36 +- api/lib/models/group/model.freezed.dart | 240 --- api/lib/models/group/model.g.dart | 38 - api/lib/models/group/model.mapper.dart | 130 ++ api/lib/models/label/model.dart | 35 +- api/lib/models/label/model.freezed.dart | 234 --- api/lib/models/label/model.g.dart | 36 - api/lib/models/label/model.mapper.dart | 129 ++ api/lib/models/model.dart | 20 +- api/lib/models/model.freezed.dart | 167 -- api/lib/models/model.mapper.dart | 123 ++ api/lib/models/note/model.dart | 80 +- api/lib/models/note/model.freezed.dart | 503 ----- api/lib/models/note/model.g.dart | 68 - api/lib/models/note/model.mapper.dart | 328 ++++ api/lib/models/place/model.dart | 35 +- api/lib/models/place/model.freezed.dart | 234 --- api/lib/models/place/model.g.dart | 36 - api/lib/models/place/model.mapper.dart | 129 ++ api/lib/models/user/model.dart | 43 +- api/lib/models/user/model.freezed.dart | 307 --- api/lib/models/user/model.g.dart | 46 - api/lib/models/user/model.mapper.dart | 160 ++ api/pubspec.lock | 88 +- api/pubspec.yaml | 7 +- app/lib/api/storage/remote/caldav.dart | 2 +- app/lib/main.dart | 3 + app/lib/pages/calendar/item.dart | 2 +- app/lib/pages/calendar/page.dart | 6 +- app/lib/pages/events/note.dart | 10 +- app/lib/pages/notes/note.dart | 6 +- app/lib/pages/notes/tile.dart | 2 +- app/lib/pages/notes/view.dart | 8 +- app/pubspec.lock | 28 +- tools/pubspec.lock | 10 +- 52 files changed, 2760 insertions(+), 5009 deletions(-) delete mode 100644 api/lib/helpers/converter.dart create mode 100644 api/lib/helpers/mapper.dart create mode 100644 api/lib/helpers/setup.dart delete mode 100644 api/lib/models/event/item/model.freezed.dart delete mode 100644 api/lib/models/event/item/model.g.dart create mode 100644 api/lib/models/event/item/model.mapper.dart delete mode 100644 api/lib/models/event/model.freezed.dart delete mode 100644 api/lib/models/event/model.g.dart create mode 100644 api/lib/models/event/model.mapper.dart delete mode 100644 api/lib/models/extra.freezed.dart delete mode 100644 api/lib/models/extra.g.dart create mode 100644 api/lib/models/extra.mapper.dart delete mode 100644 api/lib/models/group/model.freezed.dart delete mode 100644 api/lib/models/group/model.g.dart create mode 100644 api/lib/models/group/model.mapper.dart delete mode 100644 api/lib/models/label/model.freezed.dart delete mode 100644 api/lib/models/label/model.g.dart create mode 100644 api/lib/models/label/model.mapper.dart delete mode 100644 api/lib/models/model.freezed.dart create mode 100644 api/lib/models/model.mapper.dart delete mode 100644 api/lib/models/note/model.freezed.dart delete mode 100644 api/lib/models/note/model.g.dart create mode 100644 api/lib/models/note/model.mapper.dart delete mode 100644 api/lib/models/place/model.freezed.dart delete mode 100644 api/lib/models/place/model.g.dart create mode 100644 api/lib/models/place/model.mapper.dart delete mode 100644 api/lib/models/user/model.freezed.dart delete mode 100644 api/lib/models/user/model.g.dart create mode 100644 api/lib/models/user/model.mapper.dart diff --git a/api/lib/converters/ical.dart b/api/lib/converters/ical.dart index 7d55df04033..dc2b872b7d5 100644 --- a/api/lib/converters/ical.dart +++ b/api/lib/converters/ical.dart @@ -70,7 +70,7 @@ class ICalConverter { break; case 'BEGIN': if (value == 'VEVENT') { - currentItem = CalendarItem.fixed( + currentItem = FixedCalendarItem( eventId: currentEvent.id, ); } else if (value == 'VTODO') { diff --git a/api/lib/helpers/converter.dart b/api/lib/helpers/converter.dart deleted file mode 100644 index ddcd8fd1490..00000000000 --- a/api/lib/helpers/converter.dart +++ /dev/null @@ -1,33 +0,0 @@ -import 'dart:typed_data'; - -import 'package:dart_leap/dart_leap.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; - -class DateTimeConverter extends JsonConverter { - const DateTimeConverter(); - - @override - DateTime? fromJson(int? json) { - if (json == null) return null; - return DateTimeHelper.fromSecondsSinceEpoch(json); - } - - @override - int? toJson(DateTime? object) { - return object?.secondsSinceEpoch; - } -} - -class Uint8ListConverter extends JsonConverter> { - const Uint8ListConverter(); - - @override - Uint8List fromJson(List json) { - return Uint8List.fromList(json); - } - - @override - List toJson(Uint8List object) { - return object.toList(); - } -} diff --git a/api/lib/helpers/mapper.dart b/api/lib/helpers/mapper.dart new file mode 100644 index 00000000000..e054ec0e814 --- /dev/null +++ b/api/lib/helpers/mapper.dart @@ -0,0 +1,19 @@ +import 'package:dart_leap/dart_leap.dart'; +import 'package:dart_mappable/dart_mappable.dart'; + +class SecondsDateTimeMapper extends SimpleMapper { + const SecondsDateTimeMapper(); + + @override + DateTime decode(Object value) { + if (value is int) { + return DateTimeHelper.fromSecondsSinceEpoch(value); + } + return DateTime.now(); + } + + @override + Object? encode(DateTime? self) { + return self?.secondsSinceEpoch; + } +} diff --git a/api/lib/helpers/setup.dart b/api/lib/helpers/setup.dart new file mode 100644 index 00000000000..c87ebc0fca8 --- /dev/null +++ b/api/lib/helpers/setup.dart @@ -0,0 +1,6 @@ +import 'package:dart_mappable/dart_mappable.dart'; +import 'package:flow_api/helpers/mapper.dart'; + +void setupAPI() { + MapperContainer.globals.use(SecondsDateTimeMapper()); +} diff --git a/api/lib/models/cached.dart b/api/lib/models/cached.dart index 96ce97e3f98..7c17c68cad7 100644 --- a/api/lib/models/cached.dart +++ b/api/lib/models/cached.dart @@ -1,26 +1,25 @@ -import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:dart_mappable/dart_mappable.dart'; import 'event/item/model.dart'; import 'event/model.dart'; import 'note/model.dart'; -part 'cached.freezed.dart'; -part 'cached.g.dart'; +part 'cached.mapper.dart'; -@freezed -class CachedData with _$CachedData { - const CachedData._(); +class CachedData with CachedDataMappable { + final DateTime? lastUpdated; + final List events; + final List notebooks; + final List items; + final List notes; - const factory CachedData({ - DateTime? lastUpdated, - @Default([]) List events, - @Default([]) List notebooks, - @Default([]) List items, - @Default([]) List notes, - }) = _CachedData; - - factory CachedData.fromJson(Map json) => - _$CachedDataFromJson(json); + const CachedData({ + this.lastUpdated, + this.events = const [], + this.notebooks = const [], + this.items = const [], + this.notes = const [], + }); CachedData concat(CachedData other) { return CachedData( diff --git a/api/lib/models/event/item/model.dart b/api/lib/models/event/item/model.dart index 7a788160f11..57a2baa601e 100644 --- a/api/lib/models/event/item/model.dart +++ b/api/lib/models/event/item/model.dart @@ -1,76 +1,42 @@ import 'dart:typed_data'; -import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:dart_mappable/dart_mappable.dart'; -import '../../../helpers/converter.dart'; import '../../model.dart'; import '../model.dart'; -part 'model.freezed.dart'; -part 'model.g.dart'; +part 'model.mapper.dart'; +@MappableEnum() enum CalendarItemType { appointment, moment, pending } -@freezed -class CalendarItem - with _$CalendarItem, IdentifiedModel, NamedModel, DescriptiveModel { - const CalendarItem._(); +@MappableClass() +sealed class CalendarItem + with CalendarItemMappable, IdentifiedModel, NamedModel, DescriptiveModel { + @override + final Uint8List? id; + @override + final String name, description; + final String location; + final Uint8List? groupId, placeId, eventId; + final DateTime? start, end; + final EventStatus status; - const factory CalendarItem.fixed({ - @Uint8ListConverter() Uint8List? id, - @Default('') String name, - @Default('') String description, - @Default('') String location, - @Uint8ListConverter() Uint8List? groupId, - @Uint8ListConverter() Uint8List? placeId, - @Uint8ListConverter() Uint8List? eventId, - @Default(EventStatus.confirmed) EventStatus status, - @DateTimeConverter() DateTime? start, - @DateTimeConverter() DateTime? end, - }) = FixedCalendarItem; - - const factory CalendarItem.repeating({ - @Uint8ListConverter() Uint8List? id, - @Default('') String name, - @Default('') String description, - @Default('') String location, - @Uint8ListConverter() Uint8List? groupId, - @Uint8ListConverter() Uint8List? placeId, - @Uint8ListConverter() Uint8List? eventId, - @Default(EventStatus.confirmed) EventStatus status, - @DateTimeConverter() DateTime? start, - @DateTimeConverter() DateTime? end, - @Default(RepeatType.daily) RepeatType repeatType, - @Default(1) int interval, - @Default(0) int variation, - @Default(0) int count, - @DateTimeConverter() DateTime? until, - @Default([]) List exceptions, - }) = RepeatingCalendarItem; - - const factory CalendarItem.auto({ - @Uint8ListConverter() Uint8List? id, - @Default('') String name, - @Default('') String description, - @Default('') String location, - @Uint8ListConverter() Uint8List? groupId, - @Uint8ListConverter() Uint8List? placeId, - @Uint8ListConverter() Uint8List? eventId, - @Default(EventStatus.confirmed) EventStatus status, - @DateTimeConverter() DateTime? start, - @DateTimeConverter() DateTime? end, - @Uint8ListConverter() Uint8List? autoGroupId, - @DateTimeConverter() DateTime? searchStart, - @Default(60) int autoDuration, - }) = AutoCalendarItem; - - factory CalendarItem.fromJson(Map json) => - _$CalendarItemFromJson(json); + const CalendarItem({ + this.id, + this.name = '', + this.description = '', + this.location = '', + this.groupId, + this.placeId, + this.eventId, + this.start, + this.end, + this.status = EventStatus.confirmed, + }); factory CalendarItem.fromDatabase(Map row) => - CalendarItem.fromJson({ - ...row, - }); + CalendarItemMapper.fromMap(row); CalendarItemType get type { if (start == null && end == null) { @@ -88,6 +54,85 @@ class CalendarItem } Map toDatabase() => { - ...toJson(), + ...toMap(), }; } + +@MappableClass() +final class FixedCalendarItem extends CalendarItem + with FixedCalendarItemMappable { + const FixedCalendarItem({ + super.id, + super.name, + super.description, + super.location, + super.groupId, + super.placeId, + super.eventId, + super.start, + super.end, + super.status, + }); +} + +@MappableClass() +final class RepeatingCalendarItem extends CalendarItem + with RepeatingCalendarItemMappable { + final RepeatType repeatType; + final int interval, variation, count; + final DateTime? until; + final List exceptions; + + const RepeatingCalendarItem({ + super.id, + super.name, + super.description, + super.location, + super.groupId, + super.placeId, + super.eventId, + super.start, + super.end, + super.status, + this.repeatType = RepeatType.daily, + this.interval = 1, + this.variation = 0, + this.count = 0, + this.until, + this.exceptions = const [], + }); +} + +@MappableClass() +final class AutoCalendarItem extends CalendarItem + with AutoCalendarItemMappable { + final RepeatType repeatType; + final int interval, variation, count; + final DateTime? until; + final List exceptions; + final Uint8List? autoGroupId; + final DateTime? searchStart; + final int autoDuration; + + const AutoCalendarItem({ + super.id, + super.name, + super.description, + super.location, + super.groupId, + super.placeId, + super.eventId, + super.status, + super.start, + super.end, + this.repeatType = RepeatType.daily, + this.interval = 1, + this.variation = 0, + this.count = 0, + this.until, + this.exceptions = const [], + this.autoGroupId, + this.searchStart, + this.autoDuration = 60, + }); +} diff --git a/api/lib/models/event/item/model.freezed.dart b/api/lib/models/event/item/model.freezed.dart deleted file mode 100644 index 86106a5df8c..00000000000 --- a/api/lib/models/event/item/model.freezed.dart +++ /dev/null @@ -1,1857 +0,0 @@ -// coverage:ignore-file -// GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: type=lint -// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark - -part of 'model.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -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#adding-getters-and-methods-to-our-models'); - -CalendarItem _$CalendarItemFromJson(Map json) { - switch (json['runtimeType']) { - case 'fixed': - return FixedCalendarItem.fromJson(json); - case 'repeating': - return RepeatingCalendarItem.fromJson(json); - case 'auto': - return AutoCalendarItem.fromJson(json); - - default: - throw CheckedFromJsonException(json, 'runtimeType', 'CalendarItem', - 'Invalid union type "${json['runtimeType']}"!'); - } -} - -/// @nodoc -mixin _$CalendarItem { - @Uint8ListConverter() - Uint8List? get id => throw _privateConstructorUsedError; - String get name => throw _privateConstructorUsedError; - String get description => throw _privateConstructorUsedError; - String get location => throw _privateConstructorUsedError; - @Uint8ListConverter() - Uint8List? get groupId => throw _privateConstructorUsedError; - @Uint8ListConverter() - Uint8List? get placeId => throw _privateConstructorUsedError; - @Uint8ListConverter() - Uint8List? get eventId => throw _privateConstructorUsedError; - EventStatus get status => throw _privateConstructorUsedError; - @DateTimeConverter() - DateTime? get start => throw _privateConstructorUsedError; - @DateTimeConverter() - DateTime? get end => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult when({ - required TResult Function( - @Uint8ListConverter() Uint8List? id, - String name, - String description, - String location, - @Uint8ListConverter() Uint8List? groupId, - @Uint8ListConverter() Uint8List? placeId, - @Uint8ListConverter() Uint8List? eventId, - EventStatus status, - @DateTimeConverter() DateTime? start, - @DateTimeConverter() DateTime? end) - fixed, - required TResult Function( - @Uint8ListConverter() Uint8List? id, - String name, - String description, - String location, - @Uint8ListConverter() Uint8List? groupId, - @Uint8ListConverter() Uint8List? placeId, - @Uint8ListConverter() Uint8List? eventId, - EventStatus status, - @DateTimeConverter() DateTime? start, - @DateTimeConverter() DateTime? end, - RepeatType repeatType, - int interval, - int variation, - int count, - @DateTimeConverter() DateTime? until, - List exceptions) - repeating, - required TResult Function( - @Uint8ListConverter() Uint8List? id, - String name, - String description, - String location, - @Uint8ListConverter() Uint8List? groupId, - @Uint8ListConverter() Uint8List? placeId, - @Uint8ListConverter() Uint8List? eventId, - EventStatus status, - @DateTimeConverter() DateTime? start, - @DateTimeConverter() DateTime? end, - @Uint8ListConverter() Uint8List? autoGroupId, - @DateTimeConverter() DateTime? searchStart, - int autoDuration) - auto, - }) => - throw _privateConstructorUsedError; - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function( - @Uint8ListConverter() Uint8List? id, - String name, - String description, - String location, - @Uint8ListConverter() Uint8List? groupId, - @Uint8ListConverter() Uint8List? placeId, - @Uint8ListConverter() Uint8List? eventId, - EventStatus status, - @DateTimeConverter() DateTime? start, - @DateTimeConverter() DateTime? end)? - fixed, - TResult? Function( - @Uint8ListConverter() Uint8List? id, - String name, - String description, - String location, - @Uint8ListConverter() Uint8List? groupId, - @Uint8ListConverter() Uint8List? placeId, - @Uint8ListConverter() Uint8List? eventId, - EventStatus status, - @DateTimeConverter() DateTime? start, - @DateTimeConverter() DateTime? end, - RepeatType repeatType, - int interval, - int variation, - int count, - @DateTimeConverter() DateTime? until, - List exceptions)? - repeating, - TResult? Function( - @Uint8ListConverter() Uint8List? id, - String name, - String description, - String location, - @Uint8ListConverter() Uint8List? groupId, - @Uint8ListConverter() Uint8List? placeId, - @Uint8ListConverter() Uint8List? eventId, - EventStatus status, - @DateTimeConverter() DateTime? start, - @DateTimeConverter() DateTime? end, - @Uint8ListConverter() Uint8List? autoGroupId, - @DateTimeConverter() DateTime? searchStart, - int autoDuration)? - auto, - }) => - throw _privateConstructorUsedError; - @optionalTypeArgs - TResult maybeWhen({ - TResult Function( - @Uint8ListConverter() Uint8List? id, - String name, - String description, - String location, - @Uint8ListConverter() Uint8List? groupId, - @Uint8ListConverter() Uint8List? placeId, - @Uint8ListConverter() Uint8List? eventId, - EventStatus status, - @DateTimeConverter() DateTime? start, - @DateTimeConverter() DateTime? end)? - fixed, - TResult Function( - @Uint8ListConverter() Uint8List? id, - String name, - String description, - String location, - @Uint8ListConverter() Uint8List? groupId, - @Uint8ListConverter() Uint8List? placeId, - @Uint8ListConverter() Uint8List? eventId, - EventStatus status, - @DateTimeConverter() DateTime? start, - @DateTimeConverter() DateTime? end, - RepeatType repeatType, - int interval, - int variation, - int count, - @DateTimeConverter() DateTime? until, - List exceptions)? - repeating, - TResult Function( - @Uint8ListConverter() Uint8List? id, - String name, - String description, - String location, - @Uint8ListConverter() Uint8List? groupId, - @Uint8ListConverter() Uint8List? placeId, - @Uint8ListConverter() Uint8List? eventId, - EventStatus status, - @DateTimeConverter() DateTime? start, - @DateTimeConverter() DateTime? end, - @Uint8ListConverter() Uint8List? autoGroupId, - @DateTimeConverter() DateTime? searchStart, - int autoDuration)? - auto, - required TResult orElse(), - }) => - throw _privateConstructorUsedError; - @optionalTypeArgs - TResult map({ - required TResult Function(FixedCalendarItem value) fixed, - required TResult Function(RepeatingCalendarItem value) repeating, - required TResult Function(AutoCalendarItem value) auto, - }) => - throw _privateConstructorUsedError; - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(FixedCalendarItem value)? fixed, - TResult? Function(RepeatingCalendarItem value)? repeating, - TResult? Function(AutoCalendarItem value)? auto, - }) => - throw _privateConstructorUsedError; - @optionalTypeArgs - TResult maybeMap({ - TResult Function(FixedCalendarItem value)? fixed, - TResult Function(RepeatingCalendarItem value)? repeating, - TResult Function(AutoCalendarItem value)? auto, - required TResult orElse(), - }) => - throw _privateConstructorUsedError; - - /// Serializes this CalendarItem to a JSON map. - Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of CalendarItem - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $CalendarItemCopyWith get copyWith => - throw _privateConstructorUsedError; -} - -/// @nodoc -abstract class $CalendarItemCopyWith<$Res> { - factory $CalendarItemCopyWith( - CalendarItem value, $Res Function(CalendarItem) then) = - _$CalendarItemCopyWithImpl<$Res, CalendarItem>; - @useResult - $Res call( - {@Uint8ListConverter() Uint8List? id, - String name, - String description, - String location, - @Uint8ListConverter() Uint8List? groupId, - @Uint8ListConverter() Uint8List? placeId, - @Uint8ListConverter() Uint8List? eventId, - EventStatus status, - @DateTimeConverter() DateTime? start, - @DateTimeConverter() DateTime? end}); -} - -/// @nodoc -class _$CalendarItemCopyWithImpl<$Res, $Val extends CalendarItem> - implements $CalendarItemCopyWith<$Res> { - _$CalendarItemCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of CalendarItem - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? id = freezed, - Object? name = null, - Object? description = null, - Object? location = null, - Object? groupId = freezed, - Object? placeId = freezed, - Object? eventId = freezed, - Object? status = null, - Object? start = freezed, - Object? end = freezed, - }) { - return _then(_value.copyWith( - id: freezed == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as Uint8List?, - name: null == name - ? _value.name - : name // ignore: cast_nullable_to_non_nullable - as String, - description: null == description - ? _value.description - : description // ignore: cast_nullable_to_non_nullable - as String, - location: null == location - ? _value.location - : location // ignore: cast_nullable_to_non_nullable - as String, - groupId: freezed == groupId - ? _value.groupId - : groupId // ignore: cast_nullable_to_non_nullable - as Uint8List?, - placeId: freezed == placeId - ? _value.placeId - : placeId // ignore: cast_nullable_to_non_nullable - as Uint8List?, - eventId: freezed == eventId - ? _value.eventId - : eventId // ignore: cast_nullable_to_non_nullable - as Uint8List?, - status: null == status - ? _value.status - : status // ignore: cast_nullable_to_non_nullable - as EventStatus, - start: freezed == start - ? _value.start - : start // ignore: cast_nullable_to_non_nullable - as DateTime?, - end: freezed == end - ? _value.end - : end // ignore: cast_nullable_to_non_nullable - as DateTime?, - ) as $Val); - } -} - -/// @nodoc -abstract class _$$FixedCalendarItemImplCopyWith<$Res> - implements $CalendarItemCopyWith<$Res> { - factory _$$FixedCalendarItemImplCopyWith(_$FixedCalendarItemImpl value, - $Res Function(_$FixedCalendarItemImpl) then) = - __$$FixedCalendarItemImplCopyWithImpl<$Res>; - @override - @useResult - $Res call( - {@Uint8ListConverter() Uint8List? id, - String name, - String description, - String location, - @Uint8ListConverter() Uint8List? groupId, - @Uint8ListConverter() Uint8List? placeId, - @Uint8ListConverter() Uint8List? eventId, - EventStatus status, - @DateTimeConverter() DateTime? start, - @DateTimeConverter() DateTime? end}); -} - -/// @nodoc -class __$$FixedCalendarItemImplCopyWithImpl<$Res> - extends _$CalendarItemCopyWithImpl<$Res, _$FixedCalendarItemImpl> - implements _$$FixedCalendarItemImplCopyWith<$Res> { - __$$FixedCalendarItemImplCopyWithImpl(_$FixedCalendarItemImpl _value, - $Res Function(_$FixedCalendarItemImpl) _then) - : super(_value, _then); - - /// Create a copy of CalendarItem - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? id = freezed, - Object? name = null, - Object? description = null, - Object? location = null, - Object? groupId = freezed, - Object? placeId = freezed, - Object? eventId = freezed, - Object? status = null, - Object? start = freezed, - Object? end = freezed, - }) { - return _then(_$FixedCalendarItemImpl( - id: freezed == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as Uint8List?, - name: null == name - ? _value.name - : name // ignore: cast_nullable_to_non_nullable - as String, - description: null == description - ? _value.description - : description // ignore: cast_nullable_to_non_nullable - as String, - location: null == location - ? _value.location - : location // ignore: cast_nullable_to_non_nullable - as String, - groupId: freezed == groupId - ? _value.groupId - : groupId // ignore: cast_nullable_to_non_nullable - as Uint8List?, - placeId: freezed == placeId - ? _value.placeId - : placeId // ignore: cast_nullable_to_non_nullable - as Uint8List?, - eventId: freezed == eventId - ? _value.eventId - : eventId // ignore: cast_nullable_to_non_nullable - as Uint8List?, - status: null == status - ? _value.status - : status // ignore: cast_nullable_to_non_nullable - as EventStatus, - start: freezed == start - ? _value.start - : start // ignore: cast_nullable_to_non_nullable - as DateTime?, - end: freezed == end - ? _value.end - : end // ignore: cast_nullable_to_non_nullable - as DateTime?, - )); - } -} - -/// @nodoc -@JsonSerializable() -class _$FixedCalendarItemImpl extends FixedCalendarItem { - const _$FixedCalendarItemImpl( - {@Uint8ListConverter() this.id, - this.name = '', - this.description = '', - this.location = '', - @Uint8ListConverter() this.groupId, - @Uint8ListConverter() this.placeId, - @Uint8ListConverter() this.eventId, - this.status = EventStatus.confirmed, - @DateTimeConverter() this.start, - @DateTimeConverter() this.end, - final String? $type}) - : $type = $type ?? 'fixed', - super._(); - - factory _$FixedCalendarItemImpl.fromJson(Map json) => - _$$FixedCalendarItemImplFromJson(json); - - @override - @Uint8ListConverter() - final Uint8List? id; - @override - @JsonKey() - final String name; - @override - @JsonKey() - final String description; - @override - @JsonKey() - final String location; - @override - @Uint8ListConverter() - final Uint8List? groupId; - @override - @Uint8ListConverter() - final Uint8List? placeId; - @override - @Uint8ListConverter() - final Uint8List? eventId; - @override - @JsonKey() - final EventStatus status; - @override - @DateTimeConverter() - final DateTime? start; - @override - @DateTimeConverter() - final DateTime? end; - - @JsonKey(name: 'runtimeType') - final String $type; - - @override - String toString() { - return 'CalendarItem.fixed(id: $id, name: $name, description: $description, location: $location, groupId: $groupId, placeId: $placeId, eventId: $eventId, status: $status, start: $start, end: $end)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$FixedCalendarItemImpl && - const DeepCollectionEquality().equals(other.id, id) && - (identical(other.name, name) || other.name == name) && - (identical(other.description, description) || - other.description == description) && - (identical(other.location, location) || - other.location == location) && - const DeepCollectionEquality().equals(other.groupId, groupId) && - const DeepCollectionEquality().equals(other.placeId, placeId) && - const DeepCollectionEquality().equals(other.eventId, eventId) && - (identical(other.status, status) || other.status == status) && - (identical(other.start, start) || other.start == start) && - (identical(other.end, end) || other.end == end)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash( - runtimeType, - const DeepCollectionEquality().hash(id), - name, - description, - location, - const DeepCollectionEquality().hash(groupId), - const DeepCollectionEquality().hash(placeId), - const DeepCollectionEquality().hash(eventId), - status, - start, - end); - - /// Create a copy of CalendarItem - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$FixedCalendarItemImplCopyWith<_$FixedCalendarItemImpl> get copyWith => - __$$FixedCalendarItemImplCopyWithImpl<_$FixedCalendarItemImpl>( - this, _$identity); - - @override - @optionalTypeArgs - TResult when({ - required TResult Function( - @Uint8ListConverter() Uint8List? id, - String name, - String description, - String location, - @Uint8ListConverter() Uint8List? groupId, - @Uint8ListConverter() Uint8List? placeId, - @Uint8ListConverter() Uint8List? eventId, - EventStatus status, - @DateTimeConverter() DateTime? start, - @DateTimeConverter() DateTime? end) - fixed, - required TResult Function( - @Uint8ListConverter() Uint8List? id, - String name, - String description, - String location, - @Uint8ListConverter() Uint8List? groupId, - @Uint8ListConverter() Uint8List? placeId, - @Uint8ListConverter() Uint8List? eventId, - EventStatus status, - @DateTimeConverter() DateTime? start, - @DateTimeConverter() DateTime? end, - RepeatType repeatType, - int interval, - int variation, - int count, - @DateTimeConverter() DateTime? until, - List exceptions) - repeating, - required TResult Function( - @Uint8ListConverter() Uint8List? id, - String name, - String description, - String location, - @Uint8ListConverter() Uint8List? groupId, - @Uint8ListConverter() Uint8List? placeId, - @Uint8ListConverter() Uint8List? eventId, - EventStatus status, - @DateTimeConverter() DateTime? start, - @DateTimeConverter() DateTime? end, - @Uint8ListConverter() Uint8List? autoGroupId, - @DateTimeConverter() DateTime? searchStart, - int autoDuration) - auto, - }) { - return fixed(id, name, description, location, groupId, placeId, eventId, - status, start, end); - } - - @override - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function( - @Uint8ListConverter() Uint8List? id, - String name, - String description, - String location, - @Uint8ListConverter() Uint8List? groupId, - @Uint8ListConverter() Uint8List? placeId, - @Uint8ListConverter() Uint8List? eventId, - EventStatus status, - @DateTimeConverter() DateTime? start, - @DateTimeConverter() DateTime? end)? - fixed, - TResult? Function( - @Uint8ListConverter() Uint8List? id, - String name, - String description, - String location, - @Uint8ListConverter() Uint8List? groupId, - @Uint8ListConverter() Uint8List? placeId, - @Uint8ListConverter() Uint8List? eventId, - EventStatus status, - @DateTimeConverter() DateTime? start, - @DateTimeConverter() DateTime? end, - RepeatType repeatType, - int interval, - int variation, - int count, - @DateTimeConverter() DateTime? until, - List exceptions)? - repeating, - TResult? Function( - @Uint8ListConverter() Uint8List? id, - String name, - String description, - String location, - @Uint8ListConverter() Uint8List? groupId, - @Uint8ListConverter() Uint8List? placeId, - @Uint8ListConverter() Uint8List? eventId, - EventStatus status, - @DateTimeConverter() DateTime? start, - @DateTimeConverter() DateTime? end, - @Uint8ListConverter() Uint8List? autoGroupId, - @DateTimeConverter() DateTime? searchStart, - int autoDuration)? - auto, - }) { - return fixed?.call(id, name, description, location, groupId, placeId, - eventId, status, start, end); - } - - @override - @optionalTypeArgs - TResult maybeWhen({ - TResult Function( - @Uint8ListConverter() Uint8List? id, - String name, - String description, - String location, - @Uint8ListConverter() Uint8List? groupId, - @Uint8ListConverter() Uint8List? placeId, - @Uint8ListConverter() Uint8List? eventId, - EventStatus status, - @DateTimeConverter() DateTime? start, - @DateTimeConverter() DateTime? end)? - fixed, - TResult Function( - @Uint8ListConverter() Uint8List? id, - String name, - String description, - String location, - @Uint8ListConverter() Uint8List? groupId, - @Uint8ListConverter() Uint8List? placeId, - @Uint8ListConverter() Uint8List? eventId, - EventStatus status, - @DateTimeConverter() DateTime? start, - @DateTimeConverter() DateTime? end, - RepeatType repeatType, - int interval, - int variation, - int count, - @DateTimeConverter() DateTime? until, - List exceptions)? - repeating, - TResult Function( - @Uint8ListConverter() Uint8List? id, - String name, - String description, - String location, - @Uint8ListConverter() Uint8List? groupId, - @Uint8ListConverter() Uint8List? placeId, - @Uint8ListConverter() Uint8List? eventId, - EventStatus status, - @DateTimeConverter() DateTime? start, - @DateTimeConverter() DateTime? end, - @Uint8ListConverter() Uint8List? autoGroupId, - @DateTimeConverter() DateTime? searchStart, - int autoDuration)? - auto, - required TResult orElse(), - }) { - if (fixed != null) { - return fixed(id, name, description, location, groupId, placeId, eventId, - status, start, end); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map({ - required TResult Function(FixedCalendarItem value) fixed, - required TResult Function(RepeatingCalendarItem value) repeating, - required TResult Function(AutoCalendarItem value) auto, - }) { - return fixed(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(FixedCalendarItem value)? fixed, - TResult? Function(RepeatingCalendarItem value)? repeating, - TResult? Function(AutoCalendarItem value)? auto, - }) { - return fixed?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap({ - TResult Function(FixedCalendarItem value)? fixed, - TResult Function(RepeatingCalendarItem value)? repeating, - TResult Function(AutoCalendarItem value)? auto, - required TResult orElse(), - }) { - if (fixed != null) { - return fixed(this); - } - return orElse(); - } - - @override - Map toJson() { - return _$$FixedCalendarItemImplToJson( - this, - ); - } -} - -abstract class FixedCalendarItem extends CalendarItem { - const factory FixedCalendarItem( - {@Uint8ListConverter() final Uint8List? id, - final String name, - final String description, - final String location, - @Uint8ListConverter() final Uint8List? groupId, - @Uint8ListConverter() final Uint8List? placeId, - @Uint8ListConverter() final Uint8List? eventId, - final EventStatus status, - @DateTimeConverter() final DateTime? start, - @DateTimeConverter() final DateTime? end}) = _$FixedCalendarItemImpl; - const FixedCalendarItem._() : super._(); - - factory FixedCalendarItem.fromJson(Map json) = - _$FixedCalendarItemImpl.fromJson; - - @override - @Uint8ListConverter() - Uint8List? get id; - @override - String get name; - @override - String get description; - @override - String get location; - @override - @Uint8ListConverter() - Uint8List? get groupId; - @override - @Uint8ListConverter() - Uint8List? get placeId; - @override - @Uint8ListConverter() - Uint8List? get eventId; - @override - EventStatus get status; - @override - @DateTimeConverter() - DateTime? get start; - @override - @DateTimeConverter() - DateTime? get end; - - /// Create a copy of CalendarItem - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$FixedCalendarItemImplCopyWith<_$FixedCalendarItemImpl> get copyWith => - throw _privateConstructorUsedError; -} - -/// @nodoc -abstract class _$$RepeatingCalendarItemImplCopyWith<$Res> - implements $CalendarItemCopyWith<$Res> { - factory _$$RepeatingCalendarItemImplCopyWith( - _$RepeatingCalendarItemImpl value, - $Res Function(_$RepeatingCalendarItemImpl) then) = - __$$RepeatingCalendarItemImplCopyWithImpl<$Res>; - @override - @useResult - $Res call( - {@Uint8ListConverter() Uint8List? id, - String name, - String description, - String location, - @Uint8ListConverter() Uint8List? groupId, - @Uint8ListConverter() Uint8List? placeId, - @Uint8ListConverter() Uint8List? eventId, - EventStatus status, - @DateTimeConverter() DateTime? start, - @DateTimeConverter() DateTime? end, - RepeatType repeatType, - int interval, - int variation, - int count, - @DateTimeConverter() DateTime? until, - List exceptions}); -} - -/// @nodoc -class __$$RepeatingCalendarItemImplCopyWithImpl<$Res> - extends _$CalendarItemCopyWithImpl<$Res, _$RepeatingCalendarItemImpl> - implements _$$RepeatingCalendarItemImplCopyWith<$Res> { - __$$RepeatingCalendarItemImplCopyWithImpl(_$RepeatingCalendarItemImpl _value, - $Res Function(_$RepeatingCalendarItemImpl) _then) - : super(_value, _then); - - /// Create a copy of CalendarItem - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? id = freezed, - Object? name = null, - Object? description = null, - Object? location = null, - Object? groupId = freezed, - Object? placeId = freezed, - Object? eventId = freezed, - Object? status = null, - Object? start = freezed, - Object? end = freezed, - Object? repeatType = null, - Object? interval = null, - Object? variation = null, - Object? count = null, - Object? until = freezed, - Object? exceptions = null, - }) { - return _then(_$RepeatingCalendarItemImpl( - id: freezed == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as Uint8List?, - name: null == name - ? _value.name - : name // ignore: cast_nullable_to_non_nullable - as String, - description: null == description - ? _value.description - : description // ignore: cast_nullable_to_non_nullable - as String, - location: null == location - ? _value.location - : location // ignore: cast_nullable_to_non_nullable - as String, - groupId: freezed == groupId - ? _value.groupId - : groupId // ignore: cast_nullable_to_non_nullable - as Uint8List?, - placeId: freezed == placeId - ? _value.placeId - : placeId // ignore: cast_nullable_to_non_nullable - as Uint8List?, - eventId: freezed == eventId - ? _value.eventId - : eventId // ignore: cast_nullable_to_non_nullable - as Uint8List?, - status: null == status - ? _value.status - : status // ignore: cast_nullable_to_non_nullable - as EventStatus, - start: freezed == start - ? _value.start - : start // ignore: cast_nullable_to_non_nullable - as DateTime?, - end: freezed == end - ? _value.end - : end // ignore: cast_nullable_to_non_nullable - as DateTime?, - repeatType: null == repeatType - ? _value.repeatType - : repeatType // ignore: cast_nullable_to_non_nullable - as RepeatType, - interval: null == interval - ? _value.interval - : interval // ignore: cast_nullable_to_non_nullable - as int, - variation: null == variation - ? _value.variation - : variation // ignore: cast_nullable_to_non_nullable - as int, - count: null == count - ? _value.count - : count // ignore: cast_nullable_to_non_nullable - as int, - until: freezed == until - ? _value.until - : until // ignore: cast_nullable_to_non_nullable - as DateTime?, - exceptions: null == exceptions - ? _value._exceptions - : exceptions // ignore: cast_nullable_to_non_nullable - as List, - )); - } -} - -/// @nodoc -@JsonSerializable() -class _$RepeatingCalendarItemImpl extends RepeatingCalendarItem { - const _$RepeatingCalendarItemImpl( - {@Uint8ListConverter() this.id, - this.name = '', - this.description = '', - this.location = '', - @Uint8ListConverter() this.groupId, - @Uint8ListConverter() this.placeId, - @Uint8ListConverter() this.eventId, - this.status = EventStatus.confirmed, - @DateTimeConverter() this.start, - @DateTimeConverter() this.end, - this.repeatType = RepeatType.daily, - this.interval = 1, - this.variation = 0, - this.count = 0, - @DateTimeConverter() this.until, - final List exceptions = const [], - final String? $type}) - : _exceptions = exceptions, - $type = $type ?? 'repeating', - super._(); - - factory _$RepeatingCalendarItemImpl.fromJson(Map json) => - _$$RepeatingCalendarItemImplFromJson(json); - - @override - @Uint8ListConverter() - final Uint8List? id; - @override - @JsonKey() - final String name; - @override - @JsonKey() - final String description; - @override - @JsonKey() - final String location; - @override - @Uint8ListConverter() - final Uint8List? groupId; - @override - @Uint8ListConverter() - final Uint8List? placeId; - @override - @Uint8ListConverter() - final Uint8List? eventId; - @override - @JsonKey() - final EventStatus status; - @override - @DateTimeConverter() - final DateTime? start; - @override - @DateTimeConverter() - final DateTime? end; - @override - @JsonKey() - final RepeatType repeatType; - @override - @JsonKey() - final int interval; - @override - @JsonKey() - final int variation; - @override - @JsonKey() - final int count; - @override - @DateTimeConverter() - final DateTime? until; - final List _exceptions; - @override - @JsonKey() - List get exceptions { - if (_exceptions is EqualUnmodifiableListView) return _exceptions; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_exceptions); - } - - @JsonKey(name: 'runtimeType') - final String $type; - - @override - String toString() { - return 'CalendarItem.repeating(id: $id, name: $name, description: $description, location: $location, groupId: $groupId, placeId: $placeId, eventId: $eventId, status: $status, start: $start, end: $end, repeatType: $repeatType, interval: $interval, variation: $variation, count: $count, until: $until, exceptions: $exceptions)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$RepeatingCalendarItemImpl && - const DeepCollectionEquality().equals(other.id, id) && - (identical(other.name, name) || other.name == name) && - (identical(other.description, description) || - other.description == description) && - (identical(other.location, location) || - other.location == location) && - const DeepCollectionEquality().equals(other.groupId, groupId) && - const DeepCollectionEquality().equals(other.placeId, placeId) && - const DeepCollectionEquality().equals(other.eventId, eventId) && - (identical(other.status, status) || other.status == status) && - (identical(other.start, start) || other.start == start) && - (identical(other.end, end) || other.end == end) && - (identical(other.repeatType, repeatType) || - other.repeatType == repeatType) && - (identical(other.interval, interval) || - other.interval == interval) && - (identical(other.variation, variation) || - other.variation == variation) && - (identical(other.count, count) || other.count == count) && - (identical(other.until, until) || other.until == until) && - const DeepCollectionEquality() - .equals(other._exceptions, _exceptions)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash( - runtimeType, - const DeepCollectionEquality().hash(id), - name, - description, - location, - const DeepCollectionEquality().hash(groupId), - const DeepCollectionEquality().hash(placeId), - const DeepCollectionEquality().hash(eventId), - status, - start, - end, - repeatType, - interval, - variation, - count, - until, - const DeepCollectionEquality().hash(_exceptions)); - - /// Create a copy of CalendarItem - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$RepeatingCalendarItemImplCopyWith<_$RepeatingCalendarItemImpl> - get copyWith => __$$RepeatingCalendarItemImplCopyWithImpl< - _$RepeatingCalendarItemImpl>(this, _$identity); - - @override - @optionalTypeArgs - TResult when({ - required TResult Function( - @Uint8ListConverter() Uint8List? id, - String name, - String description, - String location, - @Uint8ListConverter() Uint8List? groupId, - @Uint8ListConverter() Uint8List? placeId, - @Uint8ListConverter() Uint8List? eventId, - EventStatus status, - @DateTimeConverter() DateTime? start, - @DateTimeConverter() DateTime? end) - fixed, - required TResult Function( - @Uint8ListConverter() Uint8List? id, - String name, - String description, - String location, - @Uint8ListConverter() Uint8List? groupId, - @Uint8ListConverter() Uint8List? placeId, - @Uint8ListConverter() Uint8List? eventId, - EventStatus status, - @DateTimeConverter() DateTime? start, - @DateTimeConverter() DateTime? end, - RepeatType repeatType, - int interval, - int variation, - int count, - @DateTimeConverter() DateTime? until, - List exceptions) - repeating, - required TResult Function( - @Uint8ListConverter() Uint8List? id, - String name, - String description, - String location, - @Uint8ListConverter() Uint8List? groupId, - @Uint8ListConverter() Uint8List? placeId, - @Uint8ListConverter() Uint8List? eventId, - EventStatus status, - @DateTimeConverter() DateTime? start, - @DateTimeConverter() DateTime? end, - @Uint8ListConverter() Uint8List? autoGroupId, - @DateTimeConverter() DateTime? searchStart, - int autoDuration) - auto, - }) { - return repeating( - id, - name, - description, - location, - groupId, - placeId, - eventId, - status, - start, - end, - repeatType, - interval, - variation, - count, - until, - exceptions); - } - - @override - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function( - @Uint8ListConverter() Uint8List? id, - String name, - String description, - String location, - @Uint8ListConverter() Uint8List? groupId, - @Uint8ListConverter() Uint8List? placeId, - @Uint8ListConverter() Uint8List? eventId, - EventStatus status, - @DateTimeConverter() DateTime? start, - @DateTimeConverter() DateTime? end)? - fixed, - TResult? Function( - @Uint8ListConverter() Uint8List? id, - String name, - String description, - String location, - @Uint8ListConverter() Uint8List? groupId, - @Uint8ListConverter() Uint8List? placeId, - @Uint8ListConverter() Uint8List? eventId, - EventStatus status, - @DateTimeConverter() DateTime? start, - @DateTimeConverter() DateTime? end, - RepeatType repeatType, - int interval, - int variation, - int count, - @DateTimeConverter() DateTime? until, - List exceptions)? - repeating, - TResult? Function( - @Uint8ListConverter() Uint8List? id, - String name, - String description, - String location, - @Uint8ListConverter() Uint8List? groupId, - @Uint8ListConverter() Uint8List? placeId, - @Uint8ListConverter() Uint8List? eventId, - EventStatus status, - @DateTimeConverter() DateTime? start, - @DateTimeConverter() DateTime? end, - @Uint8ListConverter() Uint8List? autoGroupId, - @DateTimeConverter() DateTime? searchStart, - int autoDuration)? - auto, - }) { - return repeating?.call( - id, - name, - description, - location, - groupId, - placeId, - eventId, - status, - start, - end, - repeatType, - interval, - variation, - count, - until, - exceptions); - } - - @override - @optionalTypeArgs - TResult maybeWhen({ - TResult Function( - @Uint8ListConverter() Uint8List? id, - String name, - String description, - String location, - @Uint8ListConverter() Uint8List? groupId, - @Uint8ListConverter() Uint8List? placeId, - @Uint8ListConverter() Uint8List? eventId, - EventStatus status, - @DateTimeConverter() DateTime? start, - @DateTimeConverter() DateTime? end)? - fixed, - TResult Function( - @Uint8ListConverter() Uint8List? id, - String name, - String description, - String location, - @Uint8ListConverter() Uint8List? groupId, - @Uint8ListConverter() Uint8List? placeId, - @Uint8ListConverter() Uint8List? eventId, - EventStatus status, - @DateTimeConverter() DateTime? start, - @DateTimeConverter() DateTime? end, - RepeatType repeatType, - int interval, - int variation, - int count, - @DateTimeConverter() DateTime? until, - List exceptions)? - repeating, - TResult Function( - @Uint8ListConverter() Uint8List? id, - String name, - String description, - String location, - @Uint8ListConverter() Uint8List? groupId, - @Uint8ListConverter() Uint8List? placeId, - @Uint8ListConverter() Uint8List? eventId, - EventStatus status, - @DateTimeConverter() DateTime? start, - @DateTimeConverter() DateTime? end, - @Uint8ListConverter() Uint8List? autoGroupId, - @DateTimeConverter() DateTime? searchStart, - int autoDuration)? - auto, - required TResult orElse(), - }) { - if (repeating != null) { - return repeating( - id, - name, - description, - location, - groupId, - placeId, - eventId, - status, - start, - end, - repeatType, - interval, - variation, - count, - until, - exceptions); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map({ - required TResult Function(FixedCalendarItem value) fixed, - required TResult Function(RepeatingCalendarItem value) repeating, - required TResult Function(AutoCalendarItem value) auto, - }) { - return repeating(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(FixedCalendarItem value)? fixed, - TResult? Function(RepeatingCalendarItem value)? repeating, - TResult? Function(AutoCalendarItem value)? auto, - }) { - return repeating?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap({ - TResult Function(FixedCalendarItem value)? fixed, - TResult Function(RepeatingCalendarItem value)? repeating, - TResult Function(AutoCalendarItem value)? auto, - required TResult orElse(), - }) { - if (repeating != null) { - return repeating(this); - } - return orElse(); - } - - @override - Map toJson() { - return _$$RepeatingCalendarItemImplToJson( - this, - ); - } -} - -abstract class RepeatingCalendarItem extends CalendarItem { - const factory RepeatingCalendarItem( - {@Uint8ListConverter() final Uint8List? id, - final String name, - final String description, - final String location, - @Uint8ListConverter() final Uint8List? groupId, - @Uint8ListConverter() final Uint8List? placeId, - @Uint8ListConverter() final Uint8List? eventId, - final EventStatus status, - @DateTimeConverter() final DateTime? start, - @DateTimeConverter() final DateTime? end, - final RepeatType repeatType, - final int interval, - final int variation, - final int count, - @DateTimeConverter() final DateTime? until, - final List exceptions}) = _$RepeatingCalendarItemImpl; - const RepeatingCalendarItem._() : super._(); - - factory RepeatingCalendarItem.fromJson(Map json) = - _$RepeatingCalendarItemImpl.fromJson; - - @override - @Uint8ListConverter() - Uint8List? get id; - @override - String get name; - @override - String get description; - @override - String get location; - @override - @Uint8ListConverter() - Uint8List? get groupId; - @override - @Uint8ListConverter() - Uint8List? get placeId; - @override - @Uint8ListConverter() - Uint8List? get eventId; - @override - EventStatus get status; - @override - @DateTimeConverter() - DateTime? get start; - @override - @DateTimeConverter() - DateTime? get end; - RepeatType get repeatType; - int get interval; - int get variation; - int get count; - @DateTimeConverter() - DateTime? get until; - List get exceptions; - - /// Create a copy of CalendarItem - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$RepeatingCalendarItemImplCopyWith<_$RepeatingCalendarItemImpl> - get copyWith => throw _privateConstructorUsedError; -} - -/// @nodoc -abstract class _$$AutoCalendarItemImplCopyWith<$Res> - implements $CalendarItemCopyWith<$Res> { - factory _$$AutoCalendarItemImplCopyWith(_$AutoCalendarItemImpl value, - $Res Function(_$AutoCalendarItemImpl) then) = - __$$AutoCalendarItemImplCopyWithImpl<$Res>; - @override - @useResult - $Res call( - {@Uint8ListConverter() Uint8List? id, - String name, - String description, - String location, - @Uint8ListConverter() Uint8List? groupId, - @Uint8ListConverter() Uint8List? placeId, - @Uint8ListConverter() Uint8List? eventId, - EventStatus status, - @DateTimeConverter() DateTime? start, - @DateTimeConverter() DateTime? end, - @Uint8ListConverter() Uint8List? autoGroupId, - @DateTimeConverter() DateTime? searchStart, - int autoDuration}); -} - -/// @nodoc -class __$$AutoCalendarItemImplCopyWithImpl<$Res> - extends _$CalendarItemCopyWithImpl<$Res, _$AutoCalendarItemImpl> - implements _$$AutoCalendarItemImplCopyWith<$Res> { - __$$AutoCalendarItemImplCopyWithImpl(_$AutoCalendarItemImpl _value, - $Res Function(_$AutoCalendarItemImpl) _then) - : super(_value, _then); - - /// Create a copy of CalendarItem - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? id = freezed, - Object? name = null, - Object? description = null, - Object? location = null, - Object? groupId = freezed, - Object? placeId = freezed, - Object? eventId = freezed, - Object? status = null, - Object? start = freezed, - Object? end = freezed, - Object? autoGroupId = freezed, - Object? searchStart = freezed, - Object? autoDuration = null, - }) { - return _then(_$AutoCalendarItemImpl( - id: freezed == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as Uint8List?, - name: null == name - ? _value.name - : name // ignore: cast_nullable_to_non_nullable - as String, - description: null == description - ? _value.description - : description // ignore: cast_nullable_to_non_nullable - as String, - location: null == location - ? _value.location - : location // ignore: cast_nullable_to_non_nullable - as String, - groupId: freezed == groupId - ? _value.groupId - : groupId // ignore: cast_nullable_to_non_nullable - as Uint8List?, - placeId: freezed == placeId - ? _value.placeId - : placeId // ignore: cast_nullable_to_non_nullable - as Uint8List?, - eventId: freezed == eventId - ? _value.eventId - : eventId // ignore: cast_nullable_to_non_nullable - as Uint8List?, - status: null == status - ? _value.status - : status // ignore: cast_nullable_to_non_nullable - as EventStatus, - start: freezed == start - ? _value.start - : start // ignore: cast_nullable_to_non_nullable - as DateTime?, - end: freezed == end - ? _value.end - : end // ignore: cast_nullable_to_non_nullable - as DateTime?, - autoGroupId: freezed == autoGroupId - ? _value.autoGroupId - : autoGroupId // ignore: cast_nullable_to_non_nullable - as Uint8List?, - searchStart: freezed == searchStart - ? _value.searchStart - : searchStart // ignore: cast_nullable_to_non_nullable - as DateTime?, - autoDuration: null == autoDuration - ? _value.autoDuration - : autoDuration // ignore: cast_nullable_to_non_nullable - as int, - )); - } -} - -/// @nodoc -@JsonSerializable() -class _$AutoCalendarItemImpl extends AutoCalendarItem { - const _$AutoCalendarItemImpl( - {@Uint8ListConverter() this.id, - this.name = '', - this.description = '', - this.location = '', - @Uint8ListConverter() this.groupId, - @Uint8ListConverter() this.placeId, - @Uint8ListConverter() this.eventId, - this.status = EventStatus.confirmed, - @DateTimeConverter() this.start, - @DateTimeConverter() this.end, - @Uint8ListConverter() this.autoGroupId, - @DateTimeConverter() this.searchStart, - this.autoDuration = 60, - final String? $type}) - : $type = $type ?? 'auto', - super._(); - - factory _$AutoCalendarItemImpl.fromJson(Map json) => - _$$AutoCalendarItemImplFromJson(json); - - @override - @Uint8ListConverter() - final Uint8List? id; - @override - @JsonKey() - final String name; - @override - @JsonKey() - final String description; - @override - @JsonKey() - final String location; - @override - @Uint8ListConverter() - final Uint8List? groupId; - @override - @Uint8ListConverter() - final Uint8List? placeId; - @override - @Uint8ListConverter() - final Uint8List? eventId; - @override - @JsonKey() - final EventStatus status; - @override - @DateTimeConverter() - final DateTime? start; - @override - @DateTimeConverter() - final DateTime? end; - @override - @Uint8ListConverter() - final Uint8List? autoGroupId; - @override - @DateTimeConverter() - final DateTime? searchStart; - @override - @JsonKey() - final int autoDuration; - - @JsonKey(name: 'runtimeType') - final String $type; - - @override - String toString() { - return 'CalendarItem.auto(id: $id, name: $name, description: $description, location: $location, groupId: $groupId, placeId: $placeId, eventId: $eventId, status: $status, start: $start, end: $end, autoGroupId: $autoGroupId, searchStart: $searchStart, autoDuration: $autoDuration)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$AutoCalendarItemImpl && - const DeepCollectionEquality().equals(other.id, id) && - (identical(other.name, name) || other.name == name) && - (identical(other.description, description) || - other.description == description) && - (identical(other.location, location) || - other.location == location) && - const DeepCollectionEquality().equals(other.groupId, groupId) && - const DeepCollectionEquality().equals(other.placeId, placeId) && - const DeepCollectionEquality().equals(other.eventId, eventId) && - (identical(other.status, status) || other.status == status) && - (identical(other.start, start) || other.start == start) && - (identical(other.end, end) || other.end == end) && - const DeepCollectionEquality() - .equals(other.autoGroupId, autoGroupId) && - (identical(other.searchStart, searchStart) || - other.searchStart == searchStart) && - (identical(other.autoDuration, autoDuration) || - other.autoDuration == autoDuration)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash( - runtimeType, - const DeepCollectionEquality().hash(id), - name, - description, - location, - const DeepCollectionEquality().hash(groupId), - const DeepCollectionEquality().hash(placeId), - const DeepCollectionEquality().hash(eventId), - status, - start, - end, - const DeepCollectionEquality().hash(autoGroupId), - searchStart, - autoDuration); - - /// Create a copy of CalendarItem - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$AutoCalendarItemImplCopyWith<_$AutoCalendarItemImpl> get copyWith => - __$$AutoCalendarItemImplCopyWithImpl<_$AutoCalendarItemImpl>( - this, _$identity); - - @override - @optionalTypeArgs - TResult when({ - required TResult Function( - @Uint8ListConverter() Uint8List? id, - String name, - String description, - String location, - @Uint8ListConverter() Uint8List? groupId, - @Uint8ListConverter() Uint8List? placeId, - @Uint8ListConverter() Uint8List? eventId, - EventStatus status, - @DateTimeConverter() DateTime? start, - @DateTimeConverter() DateTime? end) - fixed, - required TResult Function( - @Uint8ListConverter() Uint8List? id, - String name, - String description, - String location, - @Uint8ListConverter() Uint8List? groupId, - @Uint8ListConverter() Uint8List? placeId, - @Uint8ListConverter() Uint8List? eventId, - EventStatus status, - @DateTimeConverter() DateTime? start, - @DateTimeConverter() DateTime? end, - RepeatType repeatType, - int interval, - int variation, - int count, - @DateTimeConverter() DateTime? until, - List exceptions) - repeating, - required TResult Function( - @Uint8ListConverter() Uint8List? id, - String name, - String description, - String location, - @Uint8ListConverter() Uint8List? groupId, - @Uint8ListConverter() Uint8List? placeId, - @Uint8ListConverter() Uint8List? eventId, - EventStatus status, - @DateTimeConverter() DateTime? start, - @DateTimeConverter() DateTime? end, - @Uint8ListConverter() Uint8List? autoGroupId, - @DateTimeConverter() DateTime? searchStart, - int autoDuration) - auto, - }) { - return auto(id, name, description, location, groupId, placeId, eventId, - status, start, end, autoGroupId, searchStart, autoDuration); - } - - @override - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function( - @Uint8ListConverter() Uint8List? id, - String name, - String description, - String location, - @Uint8ListConverter() Uint8List? groupId, - @Uint8ListConverter() Uint8List? placeId, - @Uint8ListConverter() Uint8List? eventId, - EventStatus status, - @DateTimeConverter() DateTime? start, - @DateTimeConverter() DateTime? end)? - fixed, - TResult? Function( - @Uint8ListConverter() Uint8List? id, - String name, - String description, - String location, - @Uint8ListConverter() Uint8List? groupId, - @Uint8ListConverter() Uint8List? placeId, - @Uint8ListConverter() Uint8List? eventId, - EventStatus status, - @DateTimeConverter() DateTime? start, - @DateTimeConverter() DateTime? end, - RepeatType repeatType, - int interval, - int variation, - int count, - @DateTimeConverter() DateTime? until, - List exceptions)? - repeating, - TResult? Function( - @Uint8ListConverter() Uint8List? id, - String name, - String description, - String location, - @Uint8ListConverter() Uint8List? groupId, - @Uint8ListConverter() Uint8List? placeId, - @Uint8ListConverter() Uint8List? eventId, - EventStatus status, - @DateTimeConverter() DateTime? start, - @DateTimeConverter() DateTime? end, - @Uint8ListConverter() Uint8List? autoGroupId, - @DateTimeConverter() DateTime? searchStart, - int autoDuration)? - auto, - }) { - return auto?.call(id, name, description, location, groupId, placeId, - eventId, status, start, end, autoGroupId, searchStart, autoDuration); - } - - @override - @optionalTypeArgs - TResult maybeWhen({ - TResult Function( - @Uint8ListConverter() Uint8List? id, - String name, - String description, - String location, - @Uint8ListConverter() Uint8List? groupId, - @Uint8ListConverter() Uint8List? placeId, - @Uint8ListConverter() Uint8List? eventId, - EventStatus status, - @DateTimeConverter() DateTime? start, - @DateTimeConverter() DateTime? end)? - fixed, - TResult Function( - @Uint8ListConverter() Uint8List? id, - String name, - String description, - String location, - @Uint8ListConverter() Uint8List? groupId, - @Uint8ListConverter() Uint8List? placeId, - @Uint8ListConverter() Uint8List? eventId, - EventStatus status, - @DateTimeConverter() DateTime? start, - @DateTimeConverter() DateTime? end, - RepeatType repeatType, - int interval, - int variation, - int count, - @DateTimeConverter() DateTime? until, - List exceptions)? - repeating, - TResult Function( - @Uint8ListConverter() Uint8List? id, - String name, - String description, - String location, - @Uint8ListConverter() Uint8List? groupId, - @Uint8ListConverter() Uint8List? placeId, - @Uint8ListConverter() Uint8List? eventId, - EventStatus status, - @DateTimeConverter() DateTime? start, - @DateTimeConverter() DateTime? end, - @Uint8ListConverter() Uint8List? autoGroupId, - @DateTimeConverter() DateTime? searchStart, - int autoDuration)? - auto, - required TResult orElse(), - }) { - if (auto != null) { - return auto(id, name, description, location, groupId, placeId, eventId, - status, start, end, autoGroupId, searchStart, autoDuration); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map({ - required TResult Function(FixedCalendarItem value) fixed, - required TResult Function(RepeatingCalendarItem value) repeating, - required TResult Function(AutoCalendarItem value) auto, - }) { - return auto(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(FixedCalendarItem value)? fixed, - TResult? Function(RepeatingCalendarItem value)? repeating, - TResult? Function(AutoCalendarItem value)? auto, - }) { - return auto?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap({ - TResult Function(FixedCalendarItem value)? fixed, - TResult Function(RepeatingCalendarItem value)? repeating, - TResult Function(AutoCalendarItem value)? auto, - required TResult orElse(), - }) { - if (auto != null) { - return auto(this); - } - return orElse(); - } - - @override - Map toJson() { - return _$$AutoCalendarItemImplToJson( - this, - ); - } -} - -abstract class AutoCalendarItem extends CalendarItem { - const factory AutoCalendarItem( - {@Uint8ListConverter() final Uint8List? id, - final String name, - final String description, - final String location, - @Uint8ListConverter() final Uint8List? groupId, - @Uint8ListConverter() final Uint8List? placeId, - @Uint8ListConverter() final Uint8List? eventId, - final EventStatus status, - @DateTimeConverter() final DateTime? start, - @DateTimeConverter() final DateTime? end, - @Uint8ListConverter() final Uint8List? autoGroupId, - @DateTimeConverter() final DateTime? searchStart, - final int autoDuration}) = _$AutoCalendarItemImpl; - const AutoCalendarItem._() : super._(); - - factory AutoCalendarItem.fromJson(Map json) = - _$AutoCalendarItemImpl.fromJson; - - @override - @Uint8ListConverter() - Uint8List? get id; - @override - String get name; - @override - String get description; - @override - String get location; - @override - @Uint8ListConverter() - Uint8List? get groupId; - @override - @Uint8ListConverter() - Uint8List? get placeId; - @override - @Uint8ListConverter() - Uint8List? get eventId; - @override - EventStatus get status; - @override - @DateTimeConverter() - DateTime? get start; - @override - @DateTimeConverter() - DateTime? get end; - @Uint8ListConverter() - Uint8List? get autoGroupId; - @DateTimeConverter() - DateTime? get searchStart; - int get autoDuration; - - /// Create a copy of CalendarItem - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$AutoCalendarItemImplCopyWith<_$AutoCalendarItemImpl> get copyWith => - throw _privateConstructorUsedError; -} diff --git a/api/lib/models/event/item/model.g.dart b/api/lib/models/event/item/model.g.dart deleted file mode 100644 index 2c05b1e0384..00000000000 --- a/api/lib/models/event/item/model.g.dart +++ /dev/null @@ -1,185 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'model.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -_$FixedCalendarItemImpl _$$FixedCalendarItemImplFromJson( - Map json) => - _$FixedCalendarItemImpl( - id: _$JsonConverterFromJson, Uint8List>( - json['id'], const Uint8ListConverter().fromJson), - name: json['name'] as String? ?? '', - description: json['description'] as String? ?? '', - location: json['location'] as String? ?? '', - groupId: _$JsonConverterFromJson, Uint8List>( - json['groupId'], const Uint8ListConverter().fromJson), - placeId: _$JsonConverterFromJson, Uint8List>( - json['placeId'], const Uint8ListConverter().fromJson), - eventId: _$JsonConverterFromJson, Uint8List>( - json['eventId'], const Uint8ListConverter().fromJson), - status: $enumDecodeNullable(_$EventStatusEnumMap, json['status']) ?? - EventStatus.confirmed, - start: - const DateTimeConverter().fromJson((json['start'] as num?)?.toInt()), - end: const DateTimeConverter().fromJson((json['end'] as num?)?.toInt()), - $type: json['runtimeType'] as String?, - ); - -Map _$$FixedCalendarItemImplToJson( - _$FixedCalendarItemImpl instance) => - { - 'id': _$JsonConverterToJson, Uint8List>( - instance.id, const Uint8ListConverter().toJson), - 'name': instance.name, - 'description': instance.description, - 'location': instance.location, - 'groupId': _$JsonConverterToJson, Uint8List>( - instance.groupId, const Uint8ListConverter().toJson), - 'placeId': _$JsonConverterToJson, Uint8List>( - instance.placeId, const Uint8ListConverter().toJson), - 'eventId': _$JsonConverterToJson, Uint8List>( - instance.eventId, const Uint8ListConverter().toJson), - 'status': _$EventStatusEnumMap[instance.status]!, - 'start': const DateTimeConverter().toJson(instance.start), - 'end': const DateTimeConverter().toJson(instance.end), - 'runtimeType': instance.$type, - }; - -Value? _$JsonConverterFromJson( - Object? json, - Value? Function(Json json) fromJson, -) => - json == null ? null : fromJson(json as Json); - -const _$EventStatusEnumMap = { - EventStatus.confirmed: 'confirmed', - EventStatus.draft: 'draft', - EventStatus.cancelled: 'cancelled', -}; - -Json? _$JsonConverterToJson( - Value? value, - Json? Function(Value value) toJson, -) => - value == null ? null : toJson(value); - -_$RepeatingCalendarItemImpl _$$RepeatingCalendarItemImplFromJson( - Map json) => - _$RepeatingCalendarItemImpl( - id: _$JsonConverterFromJson, Uint8List>( - json['id'], const Uint8ListConverter().fromJson), - name: json['name'] as String? ?? '', - description: json['description'] as String? ?? '', - location: json['location'] as String? ?? '', - groupId: _$JsonConverterFromJson, Uint8List>( - json['groupId'], const Uint8ListConverter().fromJson), - placeId: _$JsonConverterFromJson, Uint8List>( - json['placeId'], const Uint8ListConverter().fromJson), - eventId: _$JsonConverterFromJson, Uint8List>( - json['eventId'], const Uint8ListConverter().fromJson), - status: $enumDecodeNullable(_$EventStatusEnumMap, json['status']) ?? - EventStatus.confirmed, - start: - const DateTimeConverter().fromJson((json['start'] as num?)?.toInt()), - end: const DateTimeConverter().fromJson((json['end'] as num?)?.toInt()), - repeatType: - $enumDecodeNullable(_$RepeatTypeEnumMap, json['repeatType']) ?? - RepeatType.daily, - interval: (json['interval'] as num?)?.toInt() ?? 1, - variation: (json['variation'] as num?)?.toInt() ?? 0, - count: (json['count'] as num?)?.toInt() ?? 0, - until: - const DateTimeConverter().fromJson((json['until'] as num?)?.toInt()), - exceptions: (json['exceptions'] as List?) - ?.map((e) => (e as num).toInt()) - .toList() ?? - const [], - $type: json['runtimeType'] as String?, - ); - -Map _$$RepeatingCalendarItemImplToJson( - _$RepeatingCalendarItemImpl instance) => - { - 'id': _$JsonConverterToJson, Uint8List>( - instance.id, const Uint8ListConverter().toJson), - 'name': instance.name, - 'description': instance.description, - 'location': instance.location, - 'groupId': _$JsonConverterToJson, Uint8List>( - instance.groupId, const Uint8ListConverter().toJson), - 'placeId': _$JsonConverterToJson, Uint8List>( - instance.placeId, const Uint8ListConverter().toJson), - 'eventId': _$JsonConverterToJson, Uint8List>( - instance.eventId, const Uint8ListConverter().toJson), - 'status': _$EventStatusEnumMap[instance.status]!, - 'start': const DateTimeConverter().toJson(instance.start), - 'end': const DateTimeConverter().toJson(instance.end), - 'repeatType': _$RepeatTypeEnumMap[instance.repeatType]!, - 'interval': instance.interval, - 'variation': instance.variation, - 'count': instance.count, - 'until': const DateTimeConverter().toJson(instance.until), - 'exceptions': instance.exceptions, - 'runtimeType': instance.$type, - }; - -const _$RepeatTypeEnumMap = { - RepeatType.daily: 'daily', - RepeatType.weekly: 'weekly', - RepeatType.monthly: 'monthly', - RepeatType.yearly: 'yearly', -}; - -_$AutoCalendarItemImpl _$$AutoCalendarItemImplFromJson( - Map json) => - _$AutoCalendarItemImpl( - id: _$JsonConverterFromJson, Uint8List>( - json['id'], const Uint8ListConverter().fromJson), - name: json['name'] as String? ?? '', - description: json['description'] as String? ?? '', - location: json['location'] as String? ?? '', - groupId: _$JsonConverterFromJson, Uint8List>( - json['groupId'], const Uint8ListConverter().fromJson), - placeId: _$JsonConverterFromJson, Uint8List>( - json['placeId'], const Uint8ListConverter().fromJson), - eventId: _$JsonConverterFromJson, Uint8List>( - json['eventId'], const Uint8ListConverter().fromJson), - status: $enumDecodeNullable(_$EventStatusEnumMap, json['status']) ?? - EventStatus.confirmed, - start: - const DateTimeConverter().fromJson((json['start'] as num?)?.toInt()), - end: const DateTimeConverter().fromJson((json['end'] as num?)?.toInt()), - autoGroupId: _$JsonConverterFromJson, Uint8List>( - json['autoGroupId'], const Uint8ListConverter().fromJson), - searchStart: const DateTimeConverter() - .fromJson((json['searchStart'] as num?)?.toInt()), - autoDuration: (json['autoDuration'] as num?)?.toInt() ?? 60, - $type: json['runtimeType'] as String?, - ); - -Map _$$AutoCalendarItemImplToJson( - _$AutoCalendarItemImpl instance) => - { - 'id': _$JsonConverterToJson, Uint8List>( - instance.id, const Uint8ListConverter().toJson), - 'name': instance.name, - 'description': instance.description, - 'location': instance.location, - 'groupId': _$JsonConverterToJson, Uint8List>( - instance.groupId, const Uint8ListConverter().toJson), - 'placeId': _$JsonConverterToJson, Uint8List>( - instance.placeId, const Uint8ListConverter().toJson), - 'eventId': _$JsonConverterToJson, Uint8List>( - instance.eventId, const Uint8ListConverter().toJson), - 'status': _$EventStatusEnumMap[instance.status]!, - 'start': const DateTimeConverter().toJson(instance.start), - 'end': const DateTimeConverter().toJson(instance.end), - 'autoGroupId': _$JsonConverterToJson, Uint8List>( - instance.autoGroupId, const Uint8ListConverter().toJson), - 'searchStart': const DateTimeConverter().toJson(instance.searchStart), - 'autoDuration': instance.autoDuration, - 'runtimeType': instance.$type, - }; diff --git a/api/lib/models/event/item/model.mapper.dart b/api/lib/models/event/item/model.mapper.dart new file mode 100644 index 00000000000..72295554045 --- /dev/null +++ b/api/lib/models/event/item/model.mapper.dart @@ -0,0 +1,898 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, unnecessary_cast, override_on_non_overriding_member +// ignore_for_file: strict_raw_type, inference_failure_on_untyped_parameter + +part of 'model.dart'; + +class CalendarItemTypeMapper extends EnumMapper { + CalendarItemTypeMapper._(); + + static CalendarItemTypeMapper? _instance; + static CalendarItemTypeMapper ensureInitialized() { + if (_instance == null) { + MapperContainer.globals.use(_instance = CalendarItemTypeMapper._()); + } + return _instance!; + } + + static CalendarItemType fromValue(dynamic value) { + ensureInitialized(); + return MapperContainer.globals.fromValue(value); + } + + @override + CalendarItemType decode(dynamic value) { + switch (value) { + case 'appointment': + return CalendarItemType.appointment; + case 'moment': + return CalendarItemType.moment; + case 'pending': + return CalendarItemType.pending; + default: + throw MapperException.unknownEnumValue(value); + } + } + + @override + dynamic encode(CalendarItemType self) { + switch (self) { + case CalendarItemType.appointment: + return 'appointment'; + case CalendarItemType.moment: + return 'moment'; + case CalendarItemType.pending: + return 'pending'; + } + } +} + +extension CalendarItemTypeMapperExtension on CalendarItemType { + String toValue() { + CalendarItemTypeMapper.ensureInitialized(); + return MapperContainer.globals.toValue(this) as String; + } +} + +class CalendarItemMapper extends ClassMapperBase { + CalendarItemMapper._(); + + static CalendarItemMapper? _instance; + static CalendarItemMapper ensureInitialized() { + if (_instance == null) { + MapperContainer.globals.use(_instance = CalendarItemMapper._()); + FixedCalendarItemMapper.ensureInitialized(); + RepeatingCalendarItemMapper.ensureInitialized(); + AutoCalendarItemMapper.ensureInitialized(); + EventStatusMapper.ensureInitialized(); + } + return _instance!; + } + + @override + final String id = 'CalendarItem'; + + static Uint8List? _$id(CalendarItem v) => v.id; + static const Field _f$id = + Field('id', _$id, opt: true); + static String _$name(CalendarItem v) => v.name; + static const Field _f$name = + Field('name', _$name, opt: true, def: ''); + static String _$description(CalendarItem v) => v.description; + static const Field _f$description = + Field('description', _$description, opt: true, def: ''); + static String _$location(CalendarItem v) => v.location; + static const Field _f$location = + Field('location', _$location, opt: true, def: ''); + static Uint8List? _$groupId(CalendarItem v) => v.groupId; + static const Field _f$groupId = + Field('groupId', _$groupId, opt: true); + static Uint8List? _$placeId(CalendarItem v) => v.placeId; + static const Field _f$placeId = + Field('placeId', _$placeId, opt: true); + static Uint8List? _$eventId(CalendarItem v) => v.eventId; + static const Field _f$eventId = + Field('eventId', _$eventId, opt: true); + static DateTime? _$start(CalendarItem v) => v.start; + static const Field _f$start = + Field('start', _$start, opt: true); + static DateTime? _$end(CalendarItem v) => v.end; + static const Field _f$end = + Field('end', _$end, opt: true); + static EventStatus _$status(CalendarItem v) => v.status; + static const Field _f$status = + Field('status', _$status, opt: true, def: EventStatus.confirmed); + + @override + final MappableFields fields = const { + #id: _f$id, + #name: _f$name, + #description: _f$description, + #location: _f$location, + #groupId: _f$groupId, + #placeId: _f$placeId, + #eventId: _f$eventId, + #start: _f$start, + #end: _f$end, + #status: _f$status, + }; + + static CalendarItem _instantiate(DecodingData data) { + throw MapperException.missingConstructor('CalendarItem'); + } + + @override + final Function instantiate = _instantiate; + + static CalendarItem fromMap(Map map) { + return ensureInitialized().decodeMap(map); + } + + static CalendarItem fromJson(String json) { + return ensureInitialized().decodeJson(json); + } +} + +mixin CalendarItemMappable { + String toJson(); + Map toMap(); + CalendarItemCopyWith get copyWith; +} + +abstract class CalendarItemCopyWith<$R, $In extends CalendarItem, $Out> + implements ClassCopyWith<$R, $In, $Out> { + $R call( + {Uint8List? id, + String? name, + String? description, + String? location, + Uint8List? groupId, + Uint8List? placeId, + Uint8List? eventId, + DateTime? start, + DateTime? end, + EventStatus? status}); + CalendarItemCopyWith<$R2, $In, $Out2> $chain<$R2, $Out2>(Then<$Out2, $R2> t); +} + +class FixedCalendarItemMapper extends ClassMapperBase { + FixedCalendarItemMapper._(); + + static FixedCalendarItemMapper? _instance; + static FixedCalendarItemMapper ensureInitialized() { + if (_instance == null) { + MapperContainer.globals.use(_instance = FixedCalendarItemMapper._()); + CalendarItemMapper.ensureInitialized(); + EventStatusMapper.ensureInitialized(); + } + return _instance!; + } + + @override + final String id = 'FixedCalendarItem'; + + static Uint8List? _$id(FixedCalendarItem v) => v.id; + static const Field _f$id = + Field('id', _$id, opt: true); + static String _$name(FixedCalendarItem v) => v.name; + static const Field _f$name = + Field('name', _$name, opt: true, def: ''); + static String _$description(FixedCalendarItem v) => v.description; + static const Field _f$description = + Field('description', _$description, opt: true, def: ''); + static String _$location(FixedCalendarItem v) => v.location; + static const Field _f$location = + Field('location', _$location, opt: true, def: ''); + static Uint8List? _$groupId(FixedCalendarItem v) => v.groupId; + static const Field _f$groupId = + Field('groupId', _$groupId, opt: true); + static Uint8List? _$placeId(FixedCalendarItem v) => v.placeId; + static const Field _f$placeId = + Field('placeId', _$placeId, opt: true); + static Uint8List? _$eventId(FixedCalendarItem v) => v.eventId; + static const Field _f$eventId = + Field('eventId', _$eventId, opt: true); + static DateTime? _$start(FixedCalendarItem v) => v.start; + static const Field _f$start = + Field('start', _$start, opt: true); + static DateTime? _$end(FixedCalendarItem v) => v.end; + static const Field _f$end = + Field('end', _$end, opt: true); + static EventStatus _$status(FixedCalendarItem v) => v.status; + static const Field _f$status = + Field('status', _$status, opt: true, def: EventStatus.confirmed); + + @override + final MappableFields fields = const { + #id: _f$id, + #name: _f$name, + #description: _f$description, + #location: _f$location, + #groupId: _f$groupId, + #placeId: _f$placeId, + #eventId: _f$eventId, + #start: _f$start, + #end: _f$end, + #status: _f$status, + }; + + static FixedCalendarItem _instantiate(DecodingData data) { + return FixedCalendarItem( + id: data.dec(_f$id), + name: data.dec(_f$name), + description: data.dec(_f$description), + location: data.dec(_f$location), + groupId: data.dec(_f$groupId), + placeId: data.dec(_f$placeId), + eventId: data.dec(_f$eventId), + start: data.dec(_f$start), + end: data.dec(_f$end), + status: data.dec(_f$status)); + } + + @override + final Function instantiate = _instantiate; + + static FixedCalendarItem fromMap(Map map) { + return ensureInitialized().decodeMap(map); + } + + static FixedCalendarItem fromJson(String json) { + return ensureInitialized().decodeJson(json); + } +} + +mixin FixedCalendarItemMappable { + String toJson() { + return FixedCalendarItemMapper.ensureInitialized() + .encodeJson(this as FixedCalendarItem); + } + + Map toMap() { + return FixedCalendarItemMapper.ensureInitialized() + .encodeMap(this as FixedCalendarItem); + } + + FixedCalendarItemCopyWith + get copyWith => _FixedCalendarItemCopyWithImpl( + this as FixedCalendarItem, $identity, $identity); + @override + String toString() { + return FixedCalendarItemMapper.ensureInitialized() + .stringifyValue(this as FixedCalendarItem); + } + + @override + bool operator ==(Object other) { + return FixedCalendarItemMapper.ensureInitialized() + .equalsValue(this as FixedCalendarItem, other); + } + + @override + int get hashCode { + return FixedCalendarItemMapper.ensureInitialized() + .hashValue(this as FixedCalendarItem); + } +} + +extension FixedCalendarItemValueCopy<$R, $Out> + on ObjectCopyWith<$R, FixedCalendarItem, $Out> { + FixedCalendarItemCopyWith<$R, FixedCalendarItem, $Out> + get $asFixedCalendarItem => + $base.as((v, t, t2) => _FixedCalendarItemCopyWithImpl(v, t, t2)); +} + +abstract class FixedCalendarItemCopyWith<$R, $In extends FixedCalendarItem, + $Out> implements CalendarItemCopyWith<$R, $In, $Out> { + @override + $R call( + {Uint8List? id, + String? name, + String? description, + String? location, + Uint8List? groupId, + Uint8List? placeId, + Uint8List? eventId, + DateTime? start, + DateTime? end, + EventStatus? status}); + FixedCalendarItemCopyWith<$R2, $In, $Out2> $chain<$R2, $Out2>( + Then<$Out2, $R2> t); +} + +class _FixedCalendarItemCopyWithImpl<$R, $Out> + extends ClassCopyWithBase<$R, FixedCalendarItem, $Out> + implements FixedCalendarItemCopyWith<$R, FixedCalendarItem, $Out> { + _FixedCalendarItemCopyWithImpl(super.value, super.then, super.then2); + + @override + late final ClassMapperBase $mapper = + FixedCalendarItemMapper.ensureInitialized(); + @override + $R call( + {Object? id = $none, + String? name, + String? description, + String? location, + Object? groupId = $none, + Object? placeId = $none, + Object? eventId = $none, + Object? start = $none, + Object? end = $none, + EventStatus? status}) => + $apply(FieldCopyWithData({ + if (id != $none) #id: id, + if (name != null) #name: name, + if (description != null) #description: description, + if (location != null) #location: location, + if (groupId != $none) #groupId: groupId, + if (placeId != $none) #placeId: placeId, + if (eventId != $none) #eventId: eventId, + if (start != $none) #start: start, + if (end != $none) #end: end, + if (status != null) #status: status + })); + @override + FixedCalendarItem $make(CopyWithData data) => FixedCalendarItem( + id: data.get(#id, or: $value.id), + name: data.get(#name, or: $value.name), + description: data.get(#description, or: $value.description), + location: data.get(#location, or: $value.location), + groupId: data.get(#groupId, or: $value.groupId), + placeId: data.get(#placeId, or: $value.placeId), + eventId: data.get(#eventId, or: $value.eventId), + start: data.get(#start, or: $value.start), + end: data.get(#end, or: $value.end), + status: data.get(#status, or: $value.status)); + + @override + FixedCalendarItemCopyWith<$R2, FixedCalendarItem, $Out2> $chain<$R2, $Out2>( + Then<$Out2, $R2> t) => + _FixedCalendarItemCopyWithImpl($value, $cast, t); +} + +class RepeatingCalendarItemMapper + extends ClassMapperBase { + RepeatingCalendarItemMapper._(); + + static RepeatingCalendarItemMapper? _instance; + static RepeatingCalendarItemMapper ensureInitialized() { + if (_instance == null) { + MapperContainer.globals.use(_instance = RepeatingCalendarItemMapper._()); + CalendarItemMapper.ensureInitialized(); + EventStatusMapper.ensureInitialized(); + RepeatTypeMapper.ensureInitialized(); + } + return _instance!; + } + + @override + final String id = 'RepeatingCalendarItem'; + + static Uint8List? _$id(RepeatingCalendarItem v) => v.id; + static const Field _f$id = + Field('id', _$id, opt: true); + static String _$name(RepeatingCalendarItem v) => v.name; + static const Field _f$name = + Field('name', _$name, opt: true, def: ''); + static String _$description(RepeatingCalendarItem v) => v.description; + static const Field _f$description = + Field('description', _$description, opt: true, def: ''); + static String _$location(RepeatingCalendarItem v) => v.location; + static const Field _f$location = + Field('location', _$location, opt: true, def: ''); + static Uint8List? _$groupId(RepeatingCalendarItem v) => v.groupId; + static const Field _f$groupId = + Field('groupId', _$groupId, opt: true); + static Uint8List? _$placeId(RepeatingCalendarItem v) => v.placeId; + static const Field _f$placeId = + Field('placeId', _$placeId, opt: true); + static Uint8List? _$eventId(RepeatingCalendarItem v) => v.eventId; + static const Field _f$eventId = + Field('eventId', _$eventId, opt: true); + static DateTime? _$start(RepeatingCalendarItem v) => v.start; + static const Field _f$start = + Field('start', _$start, opt: true); + static DateTime? _$end(RepeatingCalendarItem v) => v.end; + static const Field _f$end = + Field('end', _$end, opt: true); + static EventStatus _$status(RepeatingCalendarItem v) => v.status; + static const Field _f$status = + Field('status', _$status, opt: true, def: EventStatus.confirmed); + static RepeatType _$repeatType(RepeatingCalendarItem v) => v.repeatType; + static const Field _f$repeatType = + Field('repeatType', _$repeatType, opt: true, def: RepeatType.daily); + static int _$interval(RepeatingCalendarItem v) => v.interval; + static const Field _f$interval = + Field('interval', _$interval, opt: true, def: 1); + static int _$variation(RepeatingCalendarItem v) => v.variation; + static const Field _f$variation = + Field('variation', _$variation, opt: true, def: 0); + static int _$count(RepeatingCalendarItem v) => v.count; + static const Field _f$count = + Field('count', _$count, opt: true, def: 0); + static DateTime? _$until(RepeatingCalendarItem v) => v.until; + static const Field _f$until = + Field('until', _$until, opt: true); + static List _$exceptions(RepeatingCalendarItem v) => v.exceptions; + static const Field> _f$exceptions = + Field('exceptions', _$exceptions, opt: true, def: const []); + + @override + final MappableFields fields = const { + #id: _f$id, + #name: _f$name, + #description: _f$description, + #location: _f$location, + #groupId: _f$groupId, + #placeId: _f$placeId, + #eventId: _f$eventId, + #start: _f$start, + #end: _f$end, + #status: _f$status, + #repeatType: _f$repeatType, + #interval: _f$interval, + #variation: _f$variation, + #count: _f$count, + #until: _f$until, + #exceptions: _f$exceptions, + }; + + static RepeatingCalendarItem _instantiate(DecodingData data) { + return RepeatingCalendarItem( + id: data.dec(_f$id), + name: data.dec(_f$name), + description: data.dec(_f$description), + location: data.dec(_f$location), + groupId: data.dec(_f$groupId), + placeId: data.dec(_f$placeId), + eventId: data.dec(_f$eventId), + start: data.dec(_f$start), + end: data.dec(_f$end), + status: data.dec(_f$status), + repeatType: data.dec(_f$repeatType), + interval: data.dec(_f$interval), + variation: data.dec(_f$variation), + count: data.dec(_f$count), + until: data.dec(_f$until), + exceptions: data.dec(_f$exceptions)); + } + + @override + final Function instantiate = _instantiate; + + static RepeatingCalendarItem fromMap(Map map) { + return ensureInitialized().decodeMap(map); + } + + static RepeatingCalendarItem fromJson(String json) { + return ensureInitialized().decodeJson(json); + } +} + +mixin RepeatingCalendarItemMappable { + String toJson() { + return RepeatingCalendarItemMapper.ensureInitialized() + .encodeJson(this as RepeatingCalendarItem); + } + + Map toMap() { + return RepeatingCalendarItemMapper.ensureInitialized() + .encodeMap(this as RepeatingCalendarItem); + } + + RepeatingCalendarItemCopyWith + get copyWith => _RepeatingCalendarItemCopyWithImpl( + this as RepeatingCalendarItem, $identity, $identity); + @override + String toString() { + return RepeatingCalendarItemMapper.ensureInitialized() + .stringifyValue(this as RepeatingCalendarItem); + } + + @override + bool operator ==(Object other) { + return RepeatingCalendarItemMapper.ensureInitialized() + .equalsValue(this as RepeatingCalendarItem, other); + } + + @override + int get hashCode { + return RepeatingCalendarItemMapper.ensureInitialized() + .hashValue(this as RepeatingCalendarItem); + } +} + +extension RepeatingCalendarItemValueCopy<$R, $Out> + on ObjectCopyWith<$R, RepeatingCalendarItem, $Out> { + RepeatingCalendarItemCopyWith<$R, RepeatingCalendarItem, $Out> + get $asRepeatingCalendarItem => + $base.as((v, t, t2) => _RepeatingCalendarItemCopyWithImpl(v, t, t2)); +} + +abstract class RepeatingCalendarItemCopyWith< + $R, + $In extends RepeatingCalendarItem, + $Out> implements CalendarItemCopyWith<$R, $In, $Out> { + ListCopyWith<$R, int, ObjectCopyWith<$R, int, int>> get exceptions; + @override + $R call( + {Uint8List? id, + String? name, + String? description, + String? location, + Uint8List? groupId, + Uint8List? placeId, + Uint8List? eventId, + DateTime? start, + DateTime? end, + EventStatus? status, + RepeatType? repeatType, + int? interval, + int? variation, + int? count, + DateTime? until, + List? exceptions}); + RepeatingCalendarItemCopyWith<$R2, $In, $Out2> $chain<$R2, $Out2>( + Then<$Out2, $R2> t); +} + +class _RepeatingCalendarItemCopyWithImpl<$R, $Out> + extends ClassCopyWithBase<$R, RepeatingCalendarItem, $Out> + implements RepeatingCalendarItemCopyWith<$R, RepeatingCalendarItem, $Out> { + _RepeatingCalendarItemCopyWithImpl(super.value, super.then, super.then2); + + @override + late final ClassMapperBase $mapper = + RepeatingCalendarItemMapper.ensureInitialized(); + @override + ListCopyWith<$R, int, ObjectCopyWith<$R, int, int>> get exceptions => + ListCopyWith($value.exceptions, (v, t) => ObjectCopyWith(v, $identity, t), + (v) => call(exceptions: v)); + @override + $R call( + {Object? id = $none, + String? name, + String? description, + String? location, + Object? groupId = $none, + Object? placeId = $none, + Object? eventId = $none, + Object? start = $none, + Object? end = $none, + EventStatus? status, + RepeatType? repeatType, + int? interval, + int? variation, + int? count, + Object? until = $none, + List? exceptions}) => + $apply(FieldCopyWithData({ + if (id != $none) #id: id, + if (name != null) #name: name, + if (description != null) #description: description, + if (location != null) #location: location, + if (groupId != $none) #groupId: groupId, + if (placeId != $none) #placeId: placeId, + if (eventId != $none) #eventId: eventId, + if (start != $none) #start: start, + if (end != $none) #end: end, + if (status != null) #status: status, + if (repeatType != null) #repeatType: repeatType, + if (interval != null) #interval: interval, + if (variation != null) #variation: variation, + if (count != null) #count: count, + if (until != $none) #until: until, + if (exceptions != null) #exceptions: exceptions + })); + @override + RepeatingCalendarItem $make(CopyWithData data) => RepeatingCalendarItem( + id: data.get(#id, or: $value.id), + name: data.get(#name, or: $value.name), + description: data.get(#description, or: $value.description), + location: data.get(#location, or: $value.location), + groupId: data.get(#groupId, or: $value.groupId), + placeId: data.get(#placeId, or: $value.placeId), + eventId: data.get(#eventId, or: $value.eventId), + start: data.get(#start, or: $value.start), + end: data.get(#end, or: $value.end), + status: data.get(#status, or: $value.status), + repeatType: data.get(#repeatType, or: $value.repeatType), + interval: data.get(#interval, or: $value.interval), + variation: data.get(#variation, or: $value.variation), + count: data.get(#count, or: $value.count), + until: data.get(#until, or: $value.until), + exceptions: data.get(#exceptions, or: $value.exceptions)); + + @override + RepeatingCalendarItemCopyWith<$R2, RepeatingCalendarItem, $Out2> + $chain<$R2, $Out2>(Then<$Out2, $R2> t) => + _RepeatingCalendarItemCopyWithImpl($value, $cast, t); +} + +class AutoCalendarItemMapper extends ClassMapperBase { + AutoCalendarItemMapper._(); + + static AutoCalendarItemMapper? _instance; + static AutoCalendarItemMapper ensureInitialized() { + if (_instance == null) { + MapperContainer.globals.use(_instance = AutoCalendarItemMapper._()); + CalendarItemMapper.ensureInitialized(); + EventStatusMapper.ensureInitialized(); + RepeatTypeMapper.ensureInitialized(); + } + return _instance!; + } + + @override + final String id = 'AutoCalendarItem'; + + static Uint8List? _$id(AutoCalendarItem v) => v.id; + static const Field _f$id = + Field('id', _$id, opt: true); + static String _$name(AutoCalendarItem v) => v.name; + static const Field _f$name = + Field('name', _$name, opt: true, def: ''); + static String _$description(AutoCalendarItem v) => v.description; + static const Field _f$description = + Field('description', _$description, opt: true, def: ''); + static String _$location(AutoCalendarItem v) => v.location; + static const Field _f$location = + Field('location', _$location, opt: true, def: ''); + static Uint8List? _$groupId(AutoCalendarItem v) => v.groupId; + static const Field _f$groupId = + Field('groupId', _$groupId, opt: true); + static Uint8List? _$placeId(AutoCalendarItem v) => v.placeId; + static const Field _f$placeId = + Field('placeId', _$placeId, opt: true); + static Uint8List? _$eventId(AutoCalendarItem v) => v.eventId; + static const Field _f$eventId = + Field('eventId', _$eventId, opt: true); + static EventStatus _$status(AutoCalendarItem v) => v.status; + static const Field _f$status = + Field('status', _$status, opt: true, def: EventStatus.confirmed); + static DateTime? _$start(AutoCalendarItem v) => v.start; + static const Field _f$start = + Field('start', _$start, opt: true); + static DateTime? _$end(AutoCalendarItem v) => v.end; + static const Field _f$end = + Field('end', _$end, opt: true); + static RepeatType _$repeatType(AutoCalendarItem v) => v.repeatType; + static const Field _f$repeatType = + Field('repeatType', _$repeatType, opt: true, def: RepeatType.daily); + static int _$interval(AutoCalendarItem v) => v.interval; + static const Field _f$interval = + Field('interval', _$interval, opt: true, def: 1); + static int _$variation(AutoCalendarItem v) => v.variation; + static const Field _f$variation = + Field('variation', _$variation, opt: true, def: 0); + static int _$count(AutoCalendarItem v) => v.count; + static const Field _f$count = + Field('count', _$count, opt: true, def: 0); + static DateTime? _$until(AutoCalendarItem v) => v.until; + static const Field _f$until = + Field('until', _$until, opt: true); + static List _$exceptions(AutoCalendarItem v) => v.exceptions; + static const Field> _f$exceptions = + Field('exceptions', _$exceptions, opt: true, def: const []); + static Uint8List? _$autoGroupId(AutoCalendarItem v) => v.autoGroupId; + static const Field _f$autoGroupId = + Field('autoGroupId', _$autoGroupId, opt: true); + static DateTime? _$searchStart(AutoCalendarItem v) => v.searchStart; + static const Field _f$searchStart = + Field('searchStart', _$searchStart, opt: true); + static int _$autoDuration(AutoCalendarItem v) => v.autoDuration; + static const Field _f$autoDuration = + Field('autoDuration', _$autoDuration, opt: true, def: 60); + + @override + final MappableFields fields = const { + #id: _f$id, + #name: _f$name, + #description: _f$description, + #location: _f$location, + #groupId: _f$groupId, + #placeId: _f$placeId, + #eventId: _f$eventId, + #status: _f$status, + #start: _f$start, + #end: _f$end, + #repeatType: _f$repeatType, + #interval: _f$interval, + #variation: _f$variation, + #count: _f$count, + #until: _f$until, + #exceptions: _f$exceptions, + #autoGroupId: _f$autoGroupId, + #searchStart: _f$searchStart, + #autoDuration: _f$autoDuration, + }; + + static AutoCalendarItem _instantiate(DecodingData data) { + return AutoCalendarItem( + id: data.dec(_f$id), + name: data.dec(_f$name), + description: data.dec(_f$description), + location: data.dec(_f$location), + groupId: data.dec(_f$groupId), + placeId: data.dec(_f$placeId), + eventId: data.dec(_f$eventId), + status: data.dec(_f$status), + start: data.dec(_f$start), + end: data.dec(_f$end), + repeatType: data.dec(_f$repeatType), + interval: data.dec(_f$interval), + variation: data.dec(_f$variation), + count: data.dec(_f$count), + until: data.dec(_f$until), + exceptions: data.dec(_f$exceptions), + autoGroupId: data.dec(_f$autoGroupId), + searchStart: data.dec(_f$searchStart), + autoDuration: data.dec(_f$autoDuration)); + } + + @override + final Function instantiate = _instantiate; + + static AutoCalendarItem fromMap(Map map) { + return ensureInitialized().decodeMap(map); + } + + static AutoCalendarItem fromJson(String json) { + return ensureInitialized().decodeJson(json); + } +} + +mixin AutoCalendarItemMappable { + String toJson() { + return AutoCalendarItemMapper.ensureInitialized() + .encodeJson(this as AutoCalendarItem); + } + + Map toMap() { + return AutoCalendarItemMapper.ensureInitialized() + .encodeMap(this as AutoCalendarItem); + } + + AutoCalendarItemCopyWith + get copyWith => _AutoCalendarItemCopyWithImpl( + this as AutoCalendarItem, $identity, $identity); + @override + String toString() { + return AutoCalendarItemMapper.ensureInitialized() + .stringifyValue(this as AutoCalendarItem); + } + + @override + bool operator ==(Object other) { + return AutoCalendarItemMapper.ensureInitialized() + .equalsValue(this as AutoCalendarItem, other); + } + + @override + int get hashCode { + return AutoCalendarItemMapper.ensureInitialized() + .hashValue(this as AutoCalendarItem); + } +} + +extension AutoCalendarItemValueCopy<$R, $Out> + on ObjectCopyWith<$R, AutoCalendarItem, $Out> { + AutoCalendarItemCopyWith<$R, AutoCalendarItem, $Out> + get $asAutoCalendarItem => + $base.as((v, t, t2) => _AutoCalendarItemCopyWithImpl(v, t, t2)); +} + +abstract class AutoCalendarItemCopyWith<$R, $In extends AutoCalendarItem, $Out> + implements CalendarItemCopyWith<$R, $In, $Out> { + ListCopyWith<$R, int, ObjectCopyWith<$R, int, int>> get exceptions; + @override + $R call( + {Uint8List? id, + String? name, + String? description, + String? location, + Uint8List? groupId, + Uint8List? placeId, + Uint8List? eventId, + EventStatus? status, + DateTime? start, + DateTime? end, + RepeatType? repeatType, + int? interval, + int? variation, + int? count, + DateTime? until, + List? exceptions, + Uint8List? autoGroupId, + DateTime? searchStart, + int? autoDuration}); + AutoCalendarItemCopyWith<$R2, $In, $Out2> $chain<$R2, $Out2>( + Then<$Out2, $R2> t); +} + +class _AutoCalendarItemCopyWithImpl<$R, $Out> + extends ClassCopyWithBase<$R, AutoCalendarItem, $Out> + implements AutoCalendarItemCopyWith<$R, AutoCalendarItem, $Out> { + _AutoCalendarItemCopyWithImpl(super.value, super.then, super.then2); + + @override + late final ClassMapperBase $mapper = + AutoCalendarItemMapper.ensureInitialized(); + @override + ListCopyWith<$R, int, ObjectCopyWith<$R, int, int>> get exceptions => + ListCopyWith($value.exceptions, (v, t) => ObjectCopyWith(v, $identity, t), + (v) => call(exceptions: v)); + @override + $R call( + {Object? id = $none, + String? name, + String? description, + String? location, + Object? groupId = $none, + Object? placeId = $none, + Object? eventId = $none, + EventStatus? status, + Object? start = $none, + Object? end = $none, + RepeatType? repeatType, + int? interval, + int? variation, + int? count, + Object? until = $none, + List? exceptions, + Object? autoGroupId = $none, + Object? searchStart = $none, + int? autoDuration}) => + $apply(FieldCopyWithData({ + if (id != $none) #id: id, + if (name != null) #name: name, + if (description != null) #description: description, + if (location != null) #location: location, + if (groupId != $none) #groupId: groupId, + if (placeId != $none) #placeId: placeId, + if (eventId != $none) #eventId: eventId, + if (status != null) #status: status, + if (start != $none) #start: start, + if (end != $none) #end: end, + if (repeatType != null) #repeatType: repeatType, + if (interval != null) #interval: interval, + if (variation != null) #variation: variation, + if (count != null) #count: count, + if (until != $none) #until: until, + if (exceptions != null) #exceptions: exceptions, + if (autoGroupId != $none) #autoGroupId: autoGroupId, + if (searchStart != $none) #searchStart: searchStart, + if (autoDuration != null) #autoDuration: autoDuration + })); + @override + AutoCalendarItem $make(CopyWithData data) => AutoCalendarItem( + id: data.get(#id, or: $value.id), + name: data.get(#name, or: $value.name), + description: data.get(#description, or: $value.description), + location: data.get(#location, or: $value.location), + groupId: data.get(#groupId, or: $value.groupId), + placeId: data.get(#placeId, or: $value.placeId), + eventId: data.get(#eventId, or: $value.eventId), + status: data.get(#status, or: $value.status), + start: data.get(#start, or: $value.start), + end: data.get(#end, or: $value.end), + repeatType: data.get(#repeatType, or: $value.repeatType), + interval: data.get(#interval, or: $value.interval), + variation: data.get(#variation, or: $value.variation), + count: data.get(#count, or: $value.count), + until: data.get(#until, or: $value.until), + exceptions: data.get(#exceptions, or: $value.exceptions), + autoGroupId: data.get(#autoGroupId, or: $value.autoGroupId), + searchStart: data.get(#searchStart, or: $value.searchStart), + autoDuration: data.get(#autoDuration, or: $value.autoDuration)); + + @override + AutoCalendarItemCopyWith<$R2, AutoCalendarItem, $Out2> $chain<$R2, $Out2>( + Then<$Out2, $R2> t) => + _AutoCalendarItemCopyWithImpl($value, $cast, t); +} diff --git a/api/lib/models/event/model.dart b/api/lib/models/event/model.dart index 90f77b3bce3..eab4e66b990 100644 --- a/api/lib/models/event/model.dart +++ b/api/lib/models/event/model.dart @@ -1,58 +1,63 @@ import 'dart:convert'; import 'dart:typed_data'; -import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:dart_mappable/dart_mappable.dart'; import 'package:flow_api/models/extra.dart'; -import '../../helpers/converter.dart'; import '../model.dart'; -part 'model.freezed.dart'; -part 'model.g.dart'; - -@freezed -class Event with _$Event, IdentifiedModel, NamedModel, DescriptiveModel { - const Event._(); - - @Implements() - const factory Event({ - @Uint8ListConverter() Uint8List? id, - @Uint8ListConverter() Uint8List? parentId, - @Uint8ListConverter() Uint8List? groupId, - @Uint8ListConverter() Uint8List? placeId, - @Default(true) bool blocked, - @Default('') String name, - @Default('') String description, - @Default('') String location, - String? extra, - }) = _Event; - - factory Event.fromJson(Map json) => _$EventFromJson(json); - - factory Event.fromDatabase(Map row) => Event.fromJson({ +part 'model.mapper.dart'; + +@MappableClass() +final class Event + with EventMappable, IdentifiedModel, NamedModel, DescriptiveModel { + @override + final Uint8List? id; + final Uint8List? parentId, groupId, placeId; + final bool blocked; + @override + final String name, description; + final String location; + final String? extra; + + const Event({ + this.id, + this.parentId, + this.groupId, + this.placeId, + this.blocked = true, + this.name = '', + this.description = '', + this.location = '', + this.extra, + }); + + factory Event.fromDatabase(Map row) => EventMapper.fromMap({ ...row, 'blocked': row['blocked'] == 1, }); Map toDatabase() => { - ...toJson(), + ...toMap(), 'blocked': blocked ? 1 : 0, }; ExtraProperties? get extraProperties => - extra != null ? ExtraProperties.fromJson(jsonDecode(extra!)) : null; + extra != null ? ExtraPropertiesMapper.fromJson(extra!) : null; Event? addExtra(ExtraProperties extraProperties) => copyWith( extra: jsonEncode(extraProperties.toJson()), ); } +@MappableEnum() enum EventStatus { confirmed, draft, cancelled, } +@MappableEnum() enum RepeatType { daily, weekly, diff --git a/api/lib/models/event/model.freezed.dart b/api/lib/models/event/model.freezed.dart deleted file mode 100644 index 435f2af3328..00000000000 --- a/api/lib/models/event/model.freezed.dart +++ /dev/null @@ -1,354 +0,0 @@ -// coverage:ignore-file -// GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: type=lint -// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark - -part of 'model.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -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#adding-getters-and-methods-to-our-models'); - -Event _$EventFromJson(Map json) { - return _Event.fromJson(json); -} - -/// @nodoc -mixin _$Event { - @Uint8ListConverter() - Uint8List? get id => throw _privateConstructorUsedError; - @Uint8ListConverter() - Uint8List? get parentId => throw _privateConstructorUsedError; - @Uint8ListConverter() - Uint8List? get groupId => throw _privateConstructorUsedError; - @Uint8ListConverter() - Uint8List? get placeId => throw _privateConstructorUsedError; - bool get blocked => throw _privateConstructorUsedError; - String get name => throw _privateConstructorUsedError; - String get description => throw _privateConstructorUsedError; - String get location => throw _privateConstructorUsedError; - String? get extra => throw _privateConstructorUsedError; - - /// Serializes this Event to a JSON map. - Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of Event - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $EventCopyWith get copyWith => throw _privateConstructorUsedError; -} - -/// @nodoc -abstract class $EventCopyWith<$Res> { - factory $EventCopyWith(Event value, $Res Function(Event) then) = - _$EventCopyWithImpl<$Res, Event>; - @useResult - $Res call( - {@Uint8ListConverter() Uint8List? id, - @Uint8ListConverter() Uint8List? parentId, - @Uint8ListConverter() Uint8List? groupId, - @Uint8ListConverter() Uint8List? placeId, - bool blocked, - String name, - String description, - String location, - String? extra}); -} - -/// @nodoc -class _$EventCopyWithImpl<$Res, $Val extends Event> - implements $EventCopyWith<$Res> { - _$EventCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of Event - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? id = freezed, - Object? parentId = freezed, - Object? groupId = freezed, - Object? placeId = freezed, - Object? blocked = null, - Object? name = null, - Object? description = null, - Object? location = null, - Object? extra = freezed, - }) { - return _then(_value.copyWith( - id: freezed == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as Uint8List?, - parentId: freezed == parentId - ? _value.parentId - : parentId // ignore: cast_nullable_to_non_nullable - as Uint8List?, - groupId: freezed == groupId - ? _value.groupId - : groupId // ignore: cast_nullable_to_non_nullable - as Uint8List?, - placeId: freezed == placeId - ? _value.placeId - : placeId // ignore: cast_nullable_to_non_nullable - as Uint8List?, - blocked: null == blocked - ? _value.blocked - : blocked // ignore: cast_nullable_to_non_nullable - as bool, - name: null == name - ? _value.name - : name // ignore: cast_nullable_to_non_nullable - as String, - description: null == description - ? _value.description - : description // ignore: cast_nullable_to_non_nullable - as String, - location: null == location - ? _value.location - : location // ignore: cast_nullable_to_non_nullable - as String, - extra: freezed == extra - ? _value.extra - : extra // ignore: cast_nullable_to_non_nullable - as String?, - ) as $Val); - } -} - -/// @nodoc -abstract class _$$EventImplCopyWith<$Res> implements $EventCopyWith<$Res> { - factory _$$EventImplCopyWith( - _$EventImpl value, $Res Function(_$EventImpl) then) = - __$$EventImplCopyWithImpl<$Res>; - @override - @useResult - $Res call( - {@Uint8ListConverter() Uint8List? id, - @Uint8ListConverter() Uint8List? parentId, - @Uint8ListConverter() Uint8List? groupId, - @Uint8ListConverter() Uint8List? placeId, - bool blocked, - String name, - String description, - String location, - String? extra}); -} - -/// @nodoc -class __$$EventImplCopyWithImpl<$Res> - extends _$EventCopyWithImpl<$Res, _$EventImpl> - implements _$$EventImplCopyWith<$Res> { - __$$EventImplCopyWithImpl( - _$EventImpl _value, $Res Function(_$EventImpl) _then) - : super(_value, _then); - - /// Create a copy of Event - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? id = freezed, - Object? parentId = freezed, - Object? groupId = freezed, - Object? placeId = freezed, - Object? blocked = null, - Object? name = null, - Object? description = null, - Object? location = null, - Object? extra = freezed, - }) { - return _then(_$EventImpl( - id: freezed == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as Uint8List?, - parentId: freezed == parentId - ? _value.parentId - : parentId // ignore: cast_nullable_to_non_nullable - as Uint8List?, - groupId: freezed == groupId - ? _value.groupId - : groupId // ignore: cast_nullable_to_non_nullable - as Uint8List?, - placeId: freezed == placeId - ? _value.placeId - : placeId // ignore: cast_nullable_to_non_nullable - as Uint8List?, - blocked: null == blocked - ? _value.blocked - : blocked // ignore: cast_nullable_to_non_nullable - as bool, - name: null == name - ? _value.name - : name // ignore: cast_nullable_to_non_nullable - as String, - description: null == description - ? _value.description - : description // ignore: cast_nullable_to_non_nullable - as String, - location: null == location - ? _value.location - : location // ignore: cast_nullable_to_non_nullable - as String, - extra: freezed == extra - ? _value.extra - : extra // ignore: cast_nullable_to_non_nullable - as String?, - )); - } -} - -/// @nodoc -@JsonSerializable() -class _$EventImpl extends _Event { - const _$EventImpl( - {@Uint8ListConverter() this.id, - @Uint8ListConverter() this.parentId, - @Uint8ListConverter() this.groupId, - @Uint8ListConverter() this.placeId, - this.blocked = true, - this.name = '', - this.description = '', - this.location = '', - this.extra}) - : super._(); - - factory _$EventImpl.fromJson(Map json) => - _$$EventImplFromJson(json); - - @override - @Uint8ListConverter() - final Uint8List? id; - @override - @Uint8ListConverter() - final Uint8List? parentId; - @override - @Uint8ListConverter() - final Uint8List? groupId; - @override - @Uint8ListConverter() - final Uint8List? placeId; - @override - @JsonKey() - final bool blocked; - @override - @JsonKey() - final String name; - @override - @JsonKey() - final String description; - @override - @JsonKey() - final String location; - @override - final String? extra; - - @override - String toString() { - return 'Event(id: $id, parentId: $parentId, groupId: $groupId, placeId: $placeId, blocked: $blocked, name: $name, description: $description, location: $location, extra: $extra)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$EventImpl && - const DeepCollectionEquality().equals(other.id, id) && - const DeepCollectionEquality().equals(other.parentId, parentId) && - const DeepCollectionEquality().equals(other.groupId, groupId) && - const DeepCollectionEquality().equals(other.placeId, placeId) && - (identical(other.blocked, blocked) || other.blocked == blocked) && - (identical(other.name, name) || other.name == name) && - (identical(other.description, description) || - other.description == description) && - (identical(other.location, location) || - other.location == location) && - (identical(other.extra, extra) || other.extra == extra)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash( - runtimeType, - const DeepCollectionEquality().hash(id), - const DeepCollectionEquality().hash(parentId), - const DeepCollectionEquality().hash(groupId), - const DeepCollectionEquality().hash(placeId), - blocked, - name, - description, - location, - extra); - - /// Create a copy of Event - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$EventImplCopyWith<_$EventImpl> get copyWith => - __$$EventImplCopyWithImpl<_$EventImpl>(this, _$identity); - - @override - Map toJson() { - return _$$EventImplToJson( - this, - ); - } -} - -abstract class _Event extends Event implements DescriptiveModel { - const factory _Event( - {@Uint8ListConverter() final Uint8List? id, - @Uint8ListConverter() final Uint8List? parentId, - @Uint8ListConverter() final Uint8List? groupId, - @Uint8ListConverter() final Uint8List? placeId, - final bool blocked, - final String name, - final String description, - final String location, - final String? extra}) = _$EventImpl; - const _Event._() : super._(); - - factory _Event.fromJson(Map json) = _$EventImpl.fromJson; - - @override - @Uint8ListConverter() - Uint8List? get id; - @override - @Uint8ListConverter() - Uint8List? get parentId; - @override - @Uint8ListConverter() - Uint8List? get groupId; - @override - @Uint8ListConverter() - Uint8List? get placeId; - @override - bool get blocked; - @override - String get name; - @override - String get description; - @override - String get location; - @override - String? get extra; - - /// Create a copy of Event - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$EventImplCopyWith<_$EventImpl> get copyWith => - throw _privateConstructorUsedError; -} diff --git a/api/lib/models/event/model.g.dart b/api/lib/models/event/model.g.dart deleted file mode 100644 index b6a798eee3c..00000000000 --- a/api/lib/models/event/model.g.dart +++ /dev/null @@ -1,52 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'model.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -_$EventImpl _$$EventImplFromJson(Map json) => _$EventImpl( - id: _$JsonConverterFromJson, Uint8List>( - json['id'], const Uint8ListConverter().fromJson), - parentId: _$JsonConverterFromJson, Uint8List>( - json['parentId'], const Uint8ListConverter().fromJson), - groupId: _$JsonConverterFromJson, Uint8List>( - json['groupId'], const Uint8ListConverter().fromJson), - placeId: _$JsonConverterFromJson, Uint8List>( - json['placeId'], const Uint8ListConverter().fromJson), - blocked: json['blocked'] as bool? ?? true, - name: json['name'] as String? ?? '', - description: json['description'] as String? ?? '', - location: json['location'] as String? ?? '', - extra: json['extra'] as String?, - ); - -Map _$$EventImplToJson(_$EventImpl instance) => - { - 'id': _$JsonConverterToJson, Uint8List>( - instance.id, const Uint8ListConverter().toJson), - 'parentId': _$JsonConverterToJson, Uint8List>( - instance.parentId, const Uint8ListConverter().toJson), - 'groupId': _$JsonConverterToJson, Uint8List>( - instance.groupId, const Uint8ListConverter().toJson), - 'placeId': _$JsonConverterToJson, Uint8List>( - instance.placeId, const Uint8ListConverter().toJson), - 'blocked': instance.blocked, - 'name': instance.name, - 'description': instance.description, - 'location': instance.location, - 'extra': instance.extra, - }; - -Value? _$JsonConverterFromJson( - Object? json, - Value? Function(Json json) fromJson, -) => - json == null ? null : fromJson(json as Json); - -Json? _$JsonConverterToJson( - Value? value, - Json? Function(Value value) toJson, -) => - value == null ? null : toJson(value); diff --git a/api/lib/models/event/model.mapper.dart b/api/lib/models/event/model.mapper.dart new file mode 100644 index 00000000000..df29b46c908 --- /dev/null +++ b/api/lib/models/event/model.mapper.dart @@ -0,0 +1,282 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, unnecessary_cast, override_on_non_overriding_member +// ignore_for_file: strict_raw_type, inference_failure_on_untyped_parameter + +part of 'model.dart'; + +class EventStatusMapper extends EnumMapper { + EventStatusMapper._(); + + static EventStatusMapper? _instance; + static EventStatusMapper ensureInitialized() { + if (_instance == null) { + MapperContainer.globals.use(_instance = EventStatusMapper._()); + } + return _instance!; + } + + static EventStatus fromValue(dynamic value) { + ensureInitialized(); + return MapperContainer.globals.fromValue(value); + } + + @override + EventStatus decode(dynamic value) { + switch (value) { + case 'confirmed': + return EventStatus.confirmed; + case 'draft': + return EventStatus.draft; + case 'cancelled': + return EventStatus.cancelled; + default: + throw MapperException.unknownEnumValue(value); + } + } + + @override + dynamic encode(EventStatus self) { + switch (self) { + case EventStatus.confirmed: + return 'confirmed'; + case EventStatus.draft: + return 'draft'; + case EventStatus.cancelled: + return 'cancelled'; + } + } +} + +extension EventStatusMapperExtension on EventStatus { + String toValue() { + EventStatusMapper.ensureInitialized(); + return MapperContainer.globals.toValue(this) as String; + } +} + +class RepeatTypeMapper extends EnumMapper { + RepeatTypeMapper._(); + + static RepeatTypeMapper? _instance; + static RepeatTypeMapper ensureInitialized() { + if (_instance == null) { + MapperContainer.globals.use(_instance = RepeatTypeMapper._()); + } + return _instance!; + } + + static RepeatType fromValue(dynamic value) { + ensureInitialized(); + return MapperContainer.globals.fromValue(value); + } + + @override + RepeatType decode(dynamic value) { + switch (value) { + case 'daily': + return RepeatType.daily; + case 'weekly': + return RepeatType.weekly; + case 'monthly': + return RepeatType.monthly; + case 'yearly': + return RepeatType.yearly; + default: + throw MapperException.unknownEnumValue(value); + } + } + + @override + dynamic encode(RepeatType self) { + switch (self) { + case RepeatType.daily: + return 'daily'; + case RepeatType.weekly: + return 'weekly'; + case RepeatType.monthly: + return 'monthly'; + case RepeatType.yearly: + return 'yearly'; + } + } +} + +extension RepeatTypeMapperExtension on RepeatType { + String toValue() { + RepeatTypeMapper.ensureInitialized(); + return MapperContainer.globals.toValue(this) as String; + } +} + +class EventMapper extends ClassMapperBase { + EventMapper._(); + + static EventMapper? _instance; + static EventMapper ensureInitialized() { + if (_instance == null) { + MapperContainer.globals.use(_instance = EventMapper._()); + } + return _instance!; + } + + @override + final String id = 'Event'; + + static Uint8List? _$id(Event v) => v.id; + static const Field _f$id = Field('id', _$id, opt: true); + static Uint8List? _$parentId(Event v) => v.parentId; + static const Field _f$parentId = + Field('parentId', _$parentId, opt: true); + static Uint8List? _$groupId(Event v) => v.groupId; + static const Field _f$groupId = + Field('groupId', _$groupId, opt: true); + static Uint8List? _$placeId(Event v) => v.placeId; + static const Field _f$placeId = + Field('placeId', _$placeId, opt: true); + static bool _$blocked(Event v) => v.blocked; + static const Field _f$blocked = + Field('blocked', _$blocked, opt: true, def: true); + static String _$name(Event v) => v.name; + static const Field _f$name = + Field('name', _$name, opt: true, def: ''); + static String _$description(Event v) => v.description; + static const Field _f$description = + Field('description', _$description, opt: true, def: ''); + static String _$location(Event v) => v.location; + static const Field _f$location = + Field('location', _$location, opt: true, def: ''); + static String? _$extra(Event v) => v.extra; + static const Field _f$extra = + Field('extra', _$extra, opt: true); + + @override + final MappableFields fields = const { + #id: _f$id, + #parentId: _f$parentId, + #groupId: _f$groupId, + #placeId: _f$placeId, + #blocked: _f$blocked, + #name: _f$name, + #description: _f$description, + #location: _f$location, + #extra: _f$extra, + }; + + static Event _instantiate(DecodingData data) { + return Event( + id: data.dec(_f$id), + parentId: data.dec(_f$parentId), + groupId: data.dec(_f$groupId), + placeId: data.dec(_f$placeId), + blocked: data.dec(_f$blocked), + name: data.dec(_f$name), + description: data.dec(_f$description), + location: data.dec(_f$location), + extra: data.dec(_f$extra)); + } + + @override + final Function instantiate = _instantiate; + + static Event fromMap(Map map) { + return ensureInitialized().decodeMap(map); + } + + static Event fromJson(String json) { + return ensureInitialized().decodeJson(json); + } +} + +mixin EventMappable { + String toJson() { + return EventMapper.ensureInitialized().encodeJson(this as Event); + } + + Map toMap() { + return EventMapper.ensureInitialized().encodeMap(this as Event); + } + + EventCopyWith get copyWith => + _EventCopyWithImpl(this as Event, $identity, $identity); + @override + String toString() { + return EventMapper.ensureInitialized().stringifyValue(this as Event); + } + + @override + bool operator ==(Object other) { + return EventMapper.ensureInitialized().equalsValue(this as Event, other); + } + + @override + int get hashCode { + return EventMapper.ensureInitialized().hashValue(this as Event); + } +} + +extension EventValueCopy<$R, $Out> on ObjectCopyWith<$R, Event, $Out> { + EventCopyWith<$R, Event, $Out> get $asEvent => + $base.as((v, t, t2) => _EventCopyWithImpl(v, t, t2)); +} + +abstract class EventCopyWith<$R, $In extends Event, $Out> + implements ClassCopyWith<$R, $In, $Out> { + $R call( + {Uint8List? id, + Uint8List? parentId, + Uint8List? groupId, + Uint8List? placeId, + bool? blocked, + String? name, + String? description, + String? location, + String? extra}); + EventCopyWith<$R2, $In, $Out2> $chain<$R2, $Out2>(Then<$Out2, $R2> t); +} + +class _EventCopyWithImpl<$R, $Out> extends ClassCopyWithBase<$R, Event, $Out> + implements EventCopyWith<$R, Event, $Out> { + _EventCopyWithImpl(super.value, super.then, super.then2); + + @override + late final ClassMapperBase $mapper = EventMapper.ensureInitialized(); + @override + $R call( + {Object? id = $none, + Object? parentId = $none, + Object? groupId = $none, + Object? placeId = $none, + bool? blocked, + String? name, + String? description, + String? location, + Object? extra = $none}) => + $apply(FieldCopyWithData({ + if (id != $none) #id: id, + if (parentId != $none) #parentId: parentId, + if (groupId != $none) #groupId: groupId, + if (placeId != $none) #placeId: placeId, + if (blocked != null) #blocked: blocked, + if (name != null) #name: name, + if (description != null) #description: description, + if (location != null) #location: location, + if (extra != $none) #extra: extra + })); + @override + Event $make(CopyWithData data) => Event( + id: data.get(#id, or: $value.id), + parentId: data.get(#parentId, or: $value.parentId), + groupId: data.get(#groupId, or: $value.groupId), + placeId: data.get(#placeId, or: $value.placeId), + blocked: data.get(#blocked, or: $value.blocked), + name: data.get(#name, or: $value.name), + description: data.get(#description, or: $value.description), + location: data.get(#location, or: $value.location), + extra: data.get(#extra, or: $value.extra)); + + @override + EventCopyWith<$R2, Event, $Out2> $chain<$R2, $Out2>(Then<$Out2, $R2> t) => + _EventCopyWithImpl($value, $cast, t); +} diff --git a/api/lib/models/extra.dart b/api/lib/models/extra.dart index e74457b065a..452f80ccd0e 100644 --- a/api/lib/models/extra.dart +++ b/api/lib/models/extra.dart @@ -1,15 +1,19 @@ -import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:dart_mappable/dart_mappable.dart'; -part 'extra.g.dart'; -part 'extra.freezed.dart'; +part 'extra.mapper.dart'; -@freezed -class ExtraProperties with _$ExtraProperties { - const factory ExtraProperties.calDav({ - required String etag, - required String path, - }) = CalDavExtraProperties; +@MappableClass() +sealed class ExtraProperties with ExtraPropertiesMappable { + const ExtraProperties(); +} + +@MappableClass() +final class CalDavExtraProperties extends ExtraProperties + with CalDavExtraPropertiesMappable { + final String etag, path; - factory ExtraProperties.fromJson(Map json) => - _$ExtraPropertiesFromJson(json); + const CalDavExtraProperties({ + required this.etag, + required this.path, + }); } diff --git a/api/lib/models/extra.freezed.dart b/api/lib/models/extra.freezed.dart deleted file mode 100644 index 3ecaeebd91d..00000000000 --- a/api/lib/models/extra.freezed.dart +++ /dev/null @@ -1,272 +0,0 @@ -// coverage:ignore-file -// GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: type=lint -// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark - -part of 'extra.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -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#adding-getters-and-methods-to-our-models'); - -ExtraProperties _$ExtraPropertiesFromJson(Map json) { - return CalDavExtraProperties.fromJson(json); -} - -/// @nodoc -mixin _$ExtraProperties { - String get etag => throw _privateConstructorUsedError; - String get path => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult when({ - required TResult Function(String etag, String path) calDav, - }) => - throw _privateConstructorUsedError; - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function(String etag, String path)? calDav, - }) => - throw _privateConstructorUsedError; - @optionalTypeArgs - TResult maybeWhen({ - TResult Function(String etag, String path)? calDav, - required TResult orElse(), - }) => - throw _privateConstructorUsedError; - @optionalTypeArgs - TResult map({ - required TResult Function(CalDavExtraProperties value) calDav, - }) => - throw _privateConstructorUsedError; - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(CalDavExtraProperties value)? calDav, - }) => - throw _privateConstructorUsedError; - @optionalTypeArgs - TResult maybeMap({ - TResult Function(CalDavExtraProperties value)? calDav, - required TResult orElse(), - }) => - throw _privateConstructorUsedError; - - /// Serializes this ExtraProperties to a JSON map. - Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of ExtraProperties - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $ExtraPropertiesCopyWith get copyWith => - throw _privateConstructorUsedError; -} - -/// @nodoc -abstract class $ExtraPropertiesCopyWith<$Res> { - factory $ExtraPropertiesCopyWith( - ExtraProperties value, $Res Function(ExtraProperties) then) = - _$ExtraPropertiesCopyWithImpl<$Res, ExtraProperties>; - @useResult - $Res call({String etag, String path}); -} - -/// @nodoc -class _$ExtraPropertiesCopyWithImpl<$Res, $Val extends ExtraProperties> - implements $ExtraPropertiesCopyWith<$Res> { - _$ExtraPropertiesCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of ExtraProperties - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? etag = null, - Object? path = null, - }) { - return _then(_value.copyWith( - etag: null == etag - ? _value.etag - : etag // ignore: cast_nullable_to_non_nullable - as String, - path: null == path - ? _value.path - : path // ignore: cast_nullable_to_non_nullable - as String, - ) as $Val); - } -} - -/// @nodoc -abstract class _$$CalDavExtraPropertiesImplCopyWith<$Res> - implements $ExtraPropertiesCopyWith<$Res> { - factory _$$CalDavExtraPropertiesImplCopyWith( - _$CalDavExtraPropertiesImpl value, - $Res Function(_$CalDavExtraPropertiesImpl) then) = - __$$CalDavExtraPropertiesImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({String etag, String path}); -} - -/// @nodoc -class __$$CalDavExtraPropertiesImplCopyWithImpl<$Res> - extends _$ExtraPropertiesCopyWithImpl<$Res, _$CalDavExtraPropertiesImpl> - implements _$$CalDavExtraPropertiesImplCopyWith<$Res> { - __$$CalDavExtraPropertiesImplCopyWithImpl(_$CalDavExtraPropertiesImpl _value, - $Res Function(_$CalDavExtraPropertiesImpl) _then) - : super(_value, _then); - - /// Create a copy of ExtraProperties - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? etag = null, - Object? path = null, - }) { - return _then(_$CalDavExtraPropertiesImpl( - etag: null == etag - ? _value.etag - : etag // ignore: cast_nullable_to_non_nullable - as String, - path: null == path - ? _value.path - : path // ignore: cast_nullable_to_non_nullable - as String, - )); - } -} - -/// @nodoc -@JsonSerializable() -class _$CalDavExtraPropertiesImpl implements CalDavExtraProperties { - const _$CalDavExtraPropertiesImpl({required this.etag, required this.path}); - - factory _$CalDavExtraPropertiesImpl.fromJson(Map json) => - _$$CalDavExtraPropertiesImplFromJson(json); - - @override - final String etag; - @override - final String path; - - @override - String toString() { - return 'ExtraProperties.calDav(etag: $etag, path: $path)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$CalDavExtraPropertiesImpl && - (identical(other.etag, etag) || other.etag == etag) && - (identical(other.path, path) || other.path == path)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash(runtimeType, etag, path); - - /// Create a copy of ExtraProperties - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$CalDavExtraPropertiesImplCopyWith<_$CalDavExtraPropertiesImpl> - get copyWith => __$$CalDavExtraPropertiesImplCopyWithImpl< - _$CalDavExtraPropertiesImpl>(this, _$identity); - - @override - @optionalTypeArgs - TResult when({ - required TResult Function(String etag, String path) calDav, - }) { - return calDav(etag, path); - } - - @override - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function(String etag, String path)? calDav, - }) { - return calDav?.call(etag, path); - } - - @override - @optionalTypeArgs - TResult maybeWhen({ - TResult Function(String etag, String path)? calDav, - required TResult orElse(), - }) { - if (calDav != null) { - return calDav(etag, path); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map({ - required TResult Function(CalDavExtraProperties value) calDav, - }) { - return calDav(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(CalDavExtraProperties value)? calDav, - }) { - return calDav?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap({ - TResult Function(CalDavExtraProperties value)? calDav, - required TResult orElse(), - }) { - if (calDav != null) { - return calDav(this); - } - return orElse(); - } - - @override - Map toJson() { - return _$$CalDavExtraPropertiesImplToJson( - this, - ); - } -} - -abstract class CalDavExtraProperties implements ExtraProperties { - const factory CalDavExtraProperties( - {required final String etag, - required final String path}) = _$CalDavExtraPropertiesImpl; - - factory CalDavExtraProperties.fromJson(Map json) = - _$CalDavExtraPropertiesImpl.fromJson; - - @override - String get etag; - @override - String get path; - - /// Create a copy of ExtraProperties - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$CalDavExtraPropertiesImplCopyWith<_$CalDavExtraPropertiesImpl> - get copyWith => throw _privateConstructorUsedError; -} diff --git a/api/lib/models/extra.g.dart b/api/lib/models/extra.g.dart deleted file mode 100644 index 71a9409c83a..00000000000 --- a/api/lib/models/extra.g.dart +++ /dev/null @@ -1,21 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'extra.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -_$CalDavExtraPropertiesImpl _$$CalDavExtraPropertiesImplFromJson( - Map json) => - _$CalDavExtraPropertiesImpl( - etag: json['etag'] as String, - path: json['path'] as String, - ); - -Map _$$CalDavExtraPropertiesImplToJson( - _$CalDavExtraPropertiesImpl instance) => - { - 'etag': instance.etag, - 'path': instance.path, - }; diff --git a/api/lib/models/extra.mapper.dart b/api/lib/models/extra.mapper.dart new file mode 100644 index 00000000000..0a26f7218ae --- /dev/null +++ b/api/lib/models/extra.mapper.dart @@ -0,0 +1,174 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, unnecessary_cast, override_on_non_overriding_member +// ignore_for_file: strict_raw_type, inference_failure_on_untyped_parameter + +part of 'extra.dart'; + +class ExtraPropertiesMapper extends ClassMapperBase { + ExtraPropertiesMapper._(); + + static ExtraPropertiesMapper? _instance; + static ExtraPropertiesMapper ensureInitialized() { + if (_instance == null) { + MapperContainer.globals.use(_instance = ExtraPropertiesMapper._()); + CalDavExtraPropertiesMapper.ensureInitialized(); + } + return _instance!; + } + + @override + final String id = 'ExtraProperties'; + + @override + final MappableFields fields = const {}; + + static ExtraProperties _instantiate(DecodingData data) { + throw MapperException.missingConstructor('ExtraProperties'); + } + + @override + final Function instantiate = _instantiate; + + static ExtraProperties fromMap(Map map) { + return ensureInitialized().decodeMap(map); + } + + static ExtraProperties fromJson(String json) { + return ensureInitialized().decodeJson(json); + } +} + +mixin ExtraPropertiesMappable { + String toJson(); + Map toMap(); + ExtraPropertiesCopyWith + get copyWith; +} + +abstract class ExtraPropertiesCopyWith<$R, $In extends ExtraProperties, $Out> + implements ClassCopyWith<$R, $In, $Out> { + $R call(); + ExtraPropertiesCopyWith<$R2, $In, $Out2> $chain<$R2, $Out2>( + Then<$Out2, $R2> t); +} + +class CalDavExtraPropertiesMapper + extends ClassMapperBase { + CalDavExtraPropertiesMapper._(); + + static CalDavExtraPropertiesMapper? _instance; + static CalDavExtraPropertiesMapper ensureInitialized() { + if (_instance == null) { + MapperContainer.globals.use(_instance = CalDavExtraPropertiesMapper._()); + ExtraPropertiesMapper.ensureInitialized(); + } + return _instance!; + } + + @override + final String id = 'CalDavExtraProperties'; + + static String _$etag(CalDavExtraProperties v) => v.etag; + static const Field _f$etag = + Field('etag', _$etag); + static String _$path(CalDavExtraProperties v) => v.path; + static const Field _f$path = + Field('path', _$path); + + @override + final MappableFields fields = const { + #etag: _f$etag, + #path: _f$path, + }; + + static CalDavExtraProperties _instantiate(DecodingData data) { + return CalDavExtraProperties( + etag: data.dec(_f$etag), path: data.dec(_f$path)); + } + + @override + final Function instantiate = _instantiate; + + static CalDavExtraProperties fromMap(Map map) { + return ensureInitialized().decodeMap(map); + } + + static CalDavExtraProperties fromJson(String json) { + return ensureInitialized().decodeJson(json); + } +} + +mixin CalDavExtraPropertiesMappable { + String toJson() { + return CalDavExtraPropertiesMapper.ensureInitialized() + .encodeJson(this as CalDavExtraProperties); + } + + Map toMap() { + return CalDavExtraPropertiesMapper.ensureInitialized() + .encodeMap(this as CalDavExtraProperties); + } + + CalDavExtraPropertiesCopyWith + get copyWith => _CalDavExtraPropertiesCopyWithImpl( + this as CalDavExtraProperties, $identity, $identity); + @override + String toString() { + return CalDavExtraPropertiesMapper.ensureInitialized() + .stringifyValue(this as CalDavExtraProperties); + } + + @override + bool operator ==(Object other) { + return CalDavExtraPropertiesMapper.ensureInitialized() + .equalsValue(this as CalDavExtraProperties, other); + } + + @override + int get hashCode { + return CalDavExtraPropertiesMapper.ensureInitialized() + .hashValue(this as CalDavExtraProperties); + } +} + +extension CalDavExtraPropertiesValueCopy<$R, $Out> + on ObjectCopyWith<$R, CalDavExtraProperties, $Out> { + CalDavExtraPropertiesCopyWith<$R, CalDavExtraProperties, $Out> + get $asCalDavExtraProperties => + $base.as((v, t, t2) => _CalDavExtraPropertiesCopyWithImpl(v, t, t2)); +} + +abstract class CalDavExtraPropertiesCopyWith< + $R, + $In extends CalDavExtraProperties, + $Out> implements ExtraPropertiesCopyWith<$R, $In, $Out> { + @override + $R call({String? etag, String? path}); + CalDavExtraPropertiesCopyWith<$R2, $In, $Out2> $chain<$R2, $Out2>( + Then<$Out2, $R2> t); +} + +class _CalDavExtraPropertiesCopyWithImpl<$R, $Out> + extends ClassCopyWithBase<$R, CalDavExtraProperties, $Out> + implements CalDavExtraPropertiesCopyWith<$R, CalDavExtraProperties, $Out> { + _CalDavExtraPropertiesCopyWithImpl(super.value, super.then, super.then2); + + @override + late final ClassMapperBase $mapper = + CalDavExtraPropertiesMapper.ensureInitialized(); + @override + $R call({String? etag, String? path}) => $apply(FieldCopyWithData( + {if (etag != null) #etag: etag, if (path != null) #path: path})); + @override + CalDavExtraProperties $make(CopyWithData data) => CalDavExtraProperties( + etag: data.get(#etag, or: $value.etag), + path: data.get(#path, or: $value.path)); + + @override + CalDavExtraPropertiesCopyWith<$R2, CalDavExtraProperties, $Out2> + $chain<$R2, $Out2>(Then<$Out2, $R2> t) => + _CalDavExtraPropertiesCopyWithImpl($value, $cast, t); +} diff --git a/api/lib/models/group/model.dart b/api/lib/models/group/model.dart index 94b0aefee18..44ea5d97555 100644 --- a/api/lib/models/group/model.dart +++ b/api/lib/models/group/model.dart @@ -1,31 +1,31 @@ -import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:dart_mappable/dart_mappable.dart'; import 'dart:typed_data'; -import '../../helpers/converter.dart'; import '../model.dart'; -part 'model.freezed.dart'; -part 'model.g.dart'; +part 'model.mapper.dart'; -@freezed -class Group with _$Group, IdentifiedModel, NamedModel, DescriptiveModel { - const Group._(); +@MappableClass() +final class Group + with GroupMappable, IdentifiedModel, NamedModel, DescriptiveModel { + @override + final Uint8List? id; + @override + final String name, description; + final Uint8List? parentId; - @Implements() - const factory Group({ - @Uint8ListConverter() Uint8List? id, - @Default('') String name, - @Default('') String description, - @Uint8ListConverter() Uint8List? parentId, - }) = _Group; + const Group({ + this.id, + this.name = '', + this.description = '', + this.parentId, + }); - factory Group.fromJson(Map json) => _$GroupFromJson(json); - - factory Group.fromDatabase(Map row) => Group.fromJson({ + factory Group.fromDatabase(Map row) => GroupMapper.fromMap({ ...row, }); Map toDatabase() => { - ...toJson(), + ...toMap(), }; } diff --git a/api/lib/models/group/model.freezed.dart b/api/lib/models/group/model.freezed.dart deleted file mode 100644 index f334d4d546c..00000000000 --- a/api/lib/models/group/model.freezed.dart +++ /dev/null @@ -1,240 +0,0 @@ -// coverage:ignore-file -// GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: type=lint -// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark - -part of 'model.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -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#adding-getters-and-methods-to-our-models'); - -Group _$GroupFromJson(Map json) { - return _Group.fromJson(json); -} - -/// @nodoc -mixin _$Group { - @Uint8ListConverter() - Uint8List? get id => throw _privateConstructorUsedError; - String get name => throw _privateConstructorUsedError; - String get description => throw _privateConstructorUsedError; - @Uint8ListConverter() - Uint8List? get parentId => throw _privateConstructorUsedError; - - /// Serializes this Group to a JSON map. - Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of Group - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $GroupCopyWith get copyWith => throw _privateConstructorUsedError; -} - -/// @nodoc -abstract class $GroupCopyWith<$Res> { - factory $GroupCopyWith(Group value, $Res Function(Group) then) = - _$GroupCopyWithImpl<$Res, Group>; - @useResult - $Res call( - {@Uint8ListConverter() Uint8List? id, - String name, - String description, - @Uint8ListConverter() Uint8List? parentId}); -} - -/// @nodoc -class _$GroupCopyWithImpl<$Res, $Val extends Group> - implements $GroupCopyWith<$Res> { - _$GroupCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of Group - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? id = freezed, - Object? name = null, - Object? description = null, - Object? parentId = freezed, - }) { - return _then(_value.copyWith( - id: freezed == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as Uint8List?, - name: null == name - ? _value.name - : name // ignore: cast_nullable_to_non_nullable - as String, - description: null == description - ? _value.description - : description // ignore: cast_nullable_to_non_nullable - as String, - parentId: freezed == parentId - ? _value.parentId - : parentId // ignore: cast_nullable_to_non_nullable - as Uint8List?, - ) as $Val); - } -} - -/// @nodoc -abstract class _$$GroupImplCopyWith<$Res> implements $GroupCopyWith<$Res> { - factory _$$GroupImplCopyWith( - _$GroupImpl value, $Res Function(_$GroupImpl) then) = - __$$GroupImplCopyWithImpl<$Res>; - @override - @useResult - $Res call( - {@Uint8ListConverter() Uint8List? id, - String name, - String description, - @Uint8ListConverter() Uint8List? parentId}); -} - -/// @nodoc -class __$$GroupImplCopyWithImpl<$Res> - extends _$GroupCopyWithImpl<$Res, _$GroupImpl> - implements _$$GroupImplCopyWith<$Res> { - __$$GroupImplCopyWithImpl( - _$GroupImpl _value, $Res Function(_$GroupImpl) _then) - : super(_value, _then); - - /// Create a copy of Group - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? id = freezed, - Object? name = null, - Object? description = null, - Object? parentId = freezed, - }) { - return _then(_$GroupImpl( - id: freezed == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as Uint8List?, - name: null == name - ? _value.name - : name // ignore: cast_nullable_to_non_nullable - as String, - description: null == description - ? _value.description - : description // ignore: cast_nullable_to_non_nullable - as String, - parentId: freezed == parentId - ? _value.parentId - : parentId // ignore: cast_nullable_to_non_nullable - as Uint8List?, - )); - } -} - -/// @nodoc -@JsonSerializable() -class _$GroupImpl extends _Group { - const _$GroupImpl( - {@Uint8ListConverter() this.id, - this.name = '', - this.description = '', - @Uint8ListConverter() this.parentId}) - : super._(); - - factory _$GroupImpl.fromJson(Map json) => - _$$GroupImplFromJson(json); - - @override - @Uint8ListConverter() - final Uint8List? id; - @override - @JsonKey() - final String name; - @override - @JsonKey() - final String description; - @override - @Uint8ListConverter() - final Uint8List? parentId; - - @override - String toString() { - return 'Group(id: $id, name: $name, description: $description, parentId: $parentId)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$GroupImpl && - const DeepCollectionEquality().equals(other.id, id) && - (identical(other.name, name) || other.name == name) && - (identical(other.description, description) || - other.description == description) && - const DeepCollectionEquality().equals(other.parentId, parentId)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash( - runtimeType, - const DeepCollectionEquality().hash(id), - name, - description, - const DeepCollectionEquality().hash(parentId)); - - /// Create a copy of Group - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$GroupImplCopyWith<_$GroupImpl> get copyWith => - __$$GroupImplCopyWithImpl<_$GroupImpl>(this, _$identity); - - @override - Map toJson() { - return _$$GroupImplToJson( - this, - ); - } -} - -abstract class _Group extends Group implements DescriptiveModel { - const factory _Group( - {@Uint8ListConverter() final Uint8List? id, - final String name, - final String description, - @Uint8ListConverter() final Uint8List? parentId}) = _$GroupImpl; - const _Group._() : super._(); - - factory _Group.fromJson(Map json) = _$GroupImpl.fromJson; - - @override - @Uint8ListConverter() - Uint8List? get id; - @override - String get name; - @override - String get description; - @override - @Uint8ListConverter() - Uint8List? get parentId; - - /// Create a copy of Group - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$GroupImplCopyWith<_$GroupImpl> get copyWith => - throw _privateConstructorUsedError; -} diff --git a/api/lib/models/group/model.g.dart b/api/lib/models/group/model.g.dart deleted file mode 100644 index 2c0258bf668..00000000000 --- a/api/lib/models/group/model.g.dart +++ /dev/null @@ -1,38 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'model.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -_$GroupImpl _$$GroupImplFromJson(Map json) => _$GroupImpl( - id: _$JsonConverterFromJson, Uint8List>( - json['id'], const Uint8ListConverter().fromJson), - name: json['name'] as String? ?? '', - description: json['description'] as String? ?? '', - parentId: _$JsonConverterFromJson, Uint8List>( - json['parentId'], const Uint8ListConverter().fromJson), - ); - -Map _$$GroupImplToJson(_$GroupImpl instance) => - { - 'id': _$JsonConverterToJson, Uint8List>( - instance.id, const Uint8ListConverter().toJson), - 'name': instance.name, - 'description': instance.description, - 'parentId': _$JsonConverterToJson, Uint8List>( - instance.parentId, const Uint8ListConverter().toJson), - }; - -Value? _$JsonConverterFromJson( - Object? json, - Value? Function(Json json) fromJson, -) => - json == null ? null : fromJson(json as Json); - -Json? _$JsonConverterToJson( - Value? value, - Json? Function(Value value) toJson, -) => - value == null ? null : toJson(value); diff --git a/api/lib/models/group/model.mapper.dart b/api/lib/models/group/model.mapper.dart new file mode 100644 index 00000000000..5d2c46763fe --- /dev/null +++ b/api/lib/models/group/model.mapper.dart @@ -0,0 +1,130 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, unnecessary_cast, override_on_non_overriding_member +// ignore_for_file: strict_raw_type, inference_failure_on_untyped_parameter + +part of 'model.dart'; + +class GroupMapper extends ClassMapperBase { + GroupMapper._(); + + static GroupMapper? _instance; + static GroupMapper ensureInitialized() { + if (_instance == null) { + MapperContainer.globals.use(_instance = GroupMapper._()); + } + return _instance!; + } + + @override + final String id = 'Group'; + + static Uint8List? _$id(Group v) => v.id; + static const Field _f$id = Field('id', _$id, opt: true); + static String _$name(Group v) => v.name; + static const Field _f$name = + Field('name', _$name, opt: true, def: ''); + static String _$description(Group v) => v.description; + static const Field _f$description = + Field('description', _$description, opt: true, def: ''); + static Uint8List? _$parentId(Group v) => v.parentId; + static const Field _f$parentId = + Field('parentId', _$parentId, opt: true); + + @override + final MappableFields fields = const { + #id: _f$id, + #name: _f$name, + #description: _f$description, + #parentId: _f$parentId, + }; + + static Group _instantiate(DecodingData data) { + return Group( + id: data.dec(_f$id), + name: data.dec(_f$name), + description: data.dec(_f$description), + parentId: data.dec(_f$parentId)); + } + + @override + final Function instantiate = _instantiate; + + static Group fromMap(Map map) { + return ensureInitialized().decodeMap(map); + } + + static Group fromJson(String json) { + return ensureInitialized().decodeJson(json); + } +} + +mixin GroupMappable { + String toJson() { + return GroupMapper.ensureInitialized().encodeJson(this as Group); + } + + Map toMap() { + return GroupMapper.ensureInitialized().encodeMap(this as Group); + } + + GroupCopyWith get copyWith => + _GroupCopyWithImpl(this as Group, $identity, $identity); + @override + String toString() { + return GroupMapper.ensureInitialized().stringifyValue(this as Group); + } + + @override + bool operator ==(Object other) { + return GroupMapper.ensureInitialized().equalsValue(this as Group, other); + } + + @override + int get hashCode { + return GroupMapper.ensureInitialized().hashValue(this as Group); + } +} + +extension GroupValueCopy<$R, $Out> on ObjectCopyWith<$R, Group, $Out> { + GroupCopyWith<$R, Group, $Out> get $asGroup => + $base.as((v, t, t2) => _GroupCopyWithImpl(v, t, t2)); +} + +abstract class GroupCopyWith<$R, $In extends Group, $Out> + implements ClassCopyWith<$R, $In, $Out> { + $R call( + {Uint8List? id, String? name, String? description, Uint8List? parentId}); + GroupCopyWith<$R2, $In, $Out2> $chain<$R2, $Out2>(Then<$Out2, $R2> t); +} + +class _GroupCopyWithImpl<$R, $Out> extends ClassCopyWithBase<$R, Group, $Out> + implements GroupCopyWith<$R, Group, $Out> { + _GroupCopyWithImpl(super.value, super.then, super.then2); + + @override + late final ClassMapperBase $mapper = GroupMapper.ensureInitialized(); + @override + $R call( + {Object? id = $none, + String? name, + String? description, + Object? parentId = $none}) => + $apply(FieldCopyWithData({ + if (id != $none) #id: id, + if (name != null) #name: name, + if (description != null) #description: description, + if (parentId != $none) #parentId: parentId + })); + @override + Group $make(CopyWithData data) => Group( + id: data.get(#id, or: $value.id), + name: data.get(#name, or: $value.name), + description: data.get(#description, or: $value.description), + parentId: data.get(#parentId, or: $value.parentId)); + + @override + GroupCopyWith<$R2, Group, $Out2> $chain<$R2, $Out2>(Then<$Out2, $R2> t) => + _GroupCopyWithImpl($value, $cast, t); +} diff --git a/api/lib/models/label/model.dart b/api/lib/models/label/model.dart index e7b47045c6b..855a77fd2d3 100644 --- a/api/lib/models/label/model.dart +++ b/api/lib/models/label/model.dart @@ -1,30 +1,29 @@ -import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:dart_mappable/dart_mappable.dart'; import 'dart:typed_data'; -import 'package:flow_api/helpers/converter.dart'; import 'package:flow_api/models/model.dart'; -part 'model.freezed.dart'; -part 'model.g.dart'; +part 'model.mapper.dart'; -@freezed -class Label with _$Label, IdentifiedModel, NamedModel, DescriptiveModel { - const Label._(); +@MappableClass() +class Label with LabelMappable, IdentifiedModel, NamedModel, DescriptiveModel { + @override + final Uint8List? id; + @override + final String name, description; + final int color; - @Implements() - const factory Label({ - @Uint8ListConverter() Uint8List? id, - @Default('') String name, - @Default('') String description, - @Default(kColorBlack) int color, - }) = _Label; + const Label({ + this.id, + this.name = '', + this.description = '', + this.color = kColorBlack, + }); - factory Label.fromJson(Map json) => _$LabelFromJson(json); - - factory Label.fromDatabase(Map row) => Label.fromJson({ + factory Label.fromDatabase(Map row) => LabelMapper.fromMap({ ...row, }); Map toDatabase() => { - ...toJson(), + ...toMap(), }; } diff --git a/api/lib/models/label/model.freezed.dart b/api/lib/models/label/model.freezed.dart deleted file mode 100644 index 4aa90f30787..00000000000 --- a/api/lib/models/label/model.freezed.dart +++ /dev/null @@ -1,234 +0,0 @@ -// coverage:ignore-file -// GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: type=lint -// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark - -part of 'model.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -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#adding-getters-and-methods-to-our-models'); - -Label _$LabelFromJson(Map json) { - return _Label.fromJson(json); -} - -/// @nodoc -mixin _$Label { - @Uint8ListConverter() - Uint8List? get id => throw _privateConstructorUsedError; - String get name => throw _privateConstructorUsedError; - String get description => throw _privateConstructorUsedError; - int get color => throw _privateConstructorUsedError; - - /// Serializes this Label to a JSON map. - Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of Label - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $LabelCopyWith