From 1aba772f1df19613fd4d31aa4505a66e6bf5898f Mon Sep 17 00:00:00 2001 From: Nikolas Rimikis Date: Wed, 22 Nov 2023 15:26:02 +0100 Subject: [PATCH] feat(dynamite): support optimizing someOfs Signed-off-by: Nikolas Rimikis --- .../lib/src/models/type_result/some_of.dart | 33 ++- .../src/models/type_result/type_result.dart | 1 + .../lib/any_of.openapi.dart | 79 +----- .../lib/any_of.openapi.json | 15 ++ .../lib/one_of.openapi.dart | 79 +----- .../lib/one_of.openapi.json | 15 ++ .../lib/some_of.openapi.dart | 44 +-- .../test/any_of_test.dart | 35 +-- .../test/one_of_test.dart | 33 +-- .../neon/lib/src/pages/account_settings.dart | 7 +- .../lib/src/api/files_sharing.openapi.dart | 114 +------- .../lib/src/api/files_sharing.openapi.g.dart | 40 ++- .../lib/src/api/provisioning_api.openapi.dart | 250 +----------------- .../src/api/provisioning_api.openapi.g.dart | 76 +++--- 14 files changed, 191 insertions(+), 630 deletions(-) diff --git a/packages/dynamite/dynamite/lib/src/models/type_result/some_of.dart b/packages/dynamite/dynamite/lib/src/models/type_result/some_of.dart index 18d96ddf..a44a2994 100644 --- a/packages/dynamite/dynamite/lib/src/models/type_result/some_of.dart +++ b/packages/dynamite/dynamite/lib/src/models/type_result/some_of.dart @@ -22,10 +22,14 @@ abstract class TypeResultSomeOf extends TypeResult { return '..add(${className}Extension.serializer)'; } - late final List optimizedSubTypes = subTypes.toList(); + late final BuiltSet optimizedSubTypes = _optimizedSubTypes.toBuiltSet(); @override TypeResult get dartType { + if (optimizedSubTypes.isEmpty) { + throw StateError('SomeOf must have at least one sub type.'); + } + if (optimizedSubTypes.length == 1) { return optimizedSubTypes.single; } @@ -41,6 +45,33 @@ abstract class TypeResultSomeOf extends TypeResult { return TypeResultBase('({${record.join(',')}})'); } + Iterable get _optimizedSubTypes sync* { + var optimizedNum = false; + + final numbers = subTypes.where( + (final type) => switch (type.className) { + 'int' || 'double' || 'num' => true, + _ => false, + }, + ); + + if (numbers.length >= 2) { + yield TypeResultBase('num', nullable: true); + optimizedNum = true; + } + + yield* subTypes.where((final type) { + if (!optimizedNum) { + return true; + } + + return switch (type.className) { + 'int' || 'double' || 'num' => false, + _ => true, + }; + }); + } + @override bool operator ==(final Object other) => other is TypeResultSomeOf && diff --git a/packages/dynamite/dynamite/lib/src/models/type_result/type_result.dart b/packages/dynamite/dynamite/lib/src/models/type_result/type_result.dart index b4672f4c..cf4ecf17 100644 --- a/packages/dynamite/dynamite/lib/src/models/type_result/type_result.dart +++ b/packages/dynamite/dynamite/lib/src/models/type_result/type_result.dart @@ -1,3 +1,4 @@ +import 'package:built_collection/built_collection.dart'; import 'package:dynamite/src/helpers/dart_helpers.dart'; import 'package:meta/meta.dart'; diff --git a/packages/dynamite/dynamite_end_to_end_test/lib/any_of.openapi.dart b/packages/dynamite/dynamite_end_to_end_test/lib/any_of.openapi.dart index 96a8037a..3986d131 100644 --- a/packages/dynamite/dynamite_end_to_end_test/lib/any_of.openapi.dart +++ b/packages/dynamite/dynamite_end_to_end_test/lib/any_of.openapi.dart @@ -220,66 +220,14 @@ typedef OneObjectAnyOf = OneObjectAnyOf0; typedef OneValueAnyOf = String; -typedef AnyOfIntDouble = ({int? $int, double? $double}); +typedef AnyOfIntDouble = num; -extension AnyOfIntDoubleExtension on AnyOfIntDouble { - List get _values => [$int, $double]; - void validateOneOf() => dynamite_utils.validateOneOf(_values); - void validateAnyOf() => dynamite_utils.validateAnyOf(_values); - static Serializer get serializer => const _$AnyOfIntDoubleSerializer(); - static AnyOfIntDouble fromJson(final Object? json) => _jsonSerializers.deserializeWith(serializer, json)!; - Object? toJson() => _jsonSerializers.serializeWith(serializer, this); -} - -class _$AnyOfIntDoubleSerializer implements PrimitiveSerializer { - const _$AnyOfIntDoubleSerializer(); - - @override - Iterable get types => const [AnyOfIntDouble]; - - @override - String get wireName => 'AnyOfIntDouble'; - - @override - Object serialize( - final Serializers serializers, - final AnyOfIntDouble object, { - final FullType specifiedType = FullType.unspecified, - }) { - dynamic value; - value = object.$int; - if (value != null) { - return _jsonSerializers.serialize(value, specifiedType: const FullType(int))!; - } - value = object.$double; - if (value != null) { - return _jsonSerializers.serialize(value, specifiedType: const FullType(double))!; - } // Should not be possible after validation. - throw StateError('Tried to serialize without any value.'); - } +typedef AnyOfIntDoubleNum = num; - @override - AnyOfIntDouble deserialize( - final Serializers serializers, - final Object data, { - final FullType specifiedType = FullType.unspecified, - }) { - int? $int; - try { - $int = _jsonSerializers.deserialize(data, specifiedType: const FullType(int))! as int; - } catch (_) {} - double? $double; - try { - $double = _jsonSerializers.deserialize(data, specifiedType: const FullType(double))! as double; - } catch (_) {} - return ($int: $int, $double: $double); - } -} - -typedef AnyOfIntDoubleOther = ({int? $int, double? $double, String? string}); +typedef AnyOfIntDoubleOther = ({num? $num, String? string}); extension AnyOfIntDoubleOtherExtension on AnyOfIntDoubleOther { - List get _values => [$int, $double, string]; + List get _values => [$num, string]; void validateOneOf() => dynamite_utils.validateOneOf(_values); void validateAnyOf() => dynamite_utils.validateAnyOf(_values); static Serializer get serializer => const _$AnyOfIntDoubleOtherSerializer(); @@ -303,13 +251,9 @@ class _$AnyOfIntDoubleOtherSerializer implements PrimitiveSerializer get _values => [$int, $double]; - void validateOneOf() => dynamite_utils.validateOneOf(_values); - void validateAnyOf() => dynamite_utils.validateAnyOf(_values); - static Serializer get serializer => const _$OneOfIntDoubleSerializer(); - static OneOfIntDouble fromJson(final Object? json) => _jsonSerializers.deserializeWith(serializer, json)!; - Object? toJson() => _jsonSerializers.serializeWith(serializer, this); -} - -class _$OneOfIntDoubleSerializer implements PrimitiveSerializer { - const _$OneOfIntDoubleSerializer(); - - @override - Iterable get types => const [OneOfIntDouble]; - - @override - String get wireName => 'OneOfIntDouble'; - - @override - Object serialize( - final Serializers serializers, - final OneOfIntDouble object, { - final FullType specifiedType = FullType.unspecified, - }) { - dynamic value; - value = object.$int; - if (value != null) { - return _jsonSerializers.serialize(value, specifiedType: const FullType(int))!; - } - value = object.$double; - if (value != null) { - return _jsonSerializers.serialize(value, specifiedType: const FullType(double))!; - } // Should not be possible after validation. - throw StateError('Tried to serialize without any value.'); - } +typedef OneOfIntDoubleNum = num; - @override - OneOfIntDouble deserialize( - final Serializers serializers, - final Object data, { - final FullType specifiedType = FullType.unspecified, - }) { - int? $int; - try { - $int = _jsonSerializers.deserialize(data, specifiedType: const FullType(int))! as int; - } catch (_) {} - double? $double; - try { - $double = _jsonSerializers.deserialize(data, specifiedType: const FullType(double))! as double; - } catch (_) {} - return ($int: $int, $double: $double); - } -} - -typedef OneOfIntDoubleOther = ({int? $int, double? $double, String? string}); +typedef OneOfIntDoubleOther = ({num? $num, String? string}); extension OneOfIntDoubleOtherExtension on OneOfIntDoubleOther { - List get _values => [$int, $double, string]; + List get _values => [$num, string]; void validateOneOf() => dynamite_utils.validateOneOf(_values); void validateAnyOf() => dynamite_utils.validateAnyOf(_values); static Serializer get serializer => const _$OneOfIntDoubleOtherSerializer(); @@ -303,13 +251,9 @@ class _$OneOfIntDoubleOtherSerializer implements PrimitiveSerializer get _values => [$int, $double, string]; + List get _values => [$num, string]; void validateOneOf() => dynamite_utils.validateOneOf(_values); void validateAnyOf() => dynamite_utils.validateAnyOf(_values); static Serializer get serializer => const _$OneOfIntDoubleOtherSerializer(); @@ -55,13 +55,9 @@ class _$OneOfIntDoubleOtherSerializer implements PrimitiveSerializer get _values => [$int, $double, string]; + List get _values => [$num, string]; void validateOneOf() => dynamite_utils.validateOneOf(_values); void validateAnyOf() => dynamite_utils.validateAnyOf(_values); static Serializer get serializer => const _$AnyOfIntDoubleOtherSerializer(); @@ -119,13 +111,9 @@ class _$AnyOfIntDoubleOtherSerializer implements PrimitiveSerializer()); - object = ( - $double: null, - $int: 361, - ); + object = 361; + expect(object, isA()); + }); - json = 361; + test('AnyOfIntDoubleNum', () { + Object? object = 0.5213515036646204; + expect(object, isA()); - expect(object.toJson(), equals(json)); - expect(AnyOfIntDoubleExtension.fromJson(json), equals(object)); + object = 620; + expect(object, isA()); }); test('AnyOfIntDoubleOther', () { AnyOfIntDoubleOther object = ( - $double: 0.5971645863260784, - $int: null, + $num: 0.5971645863260784, string: null, ); @@ -96,8 +89,7 @@ void main() { expect(AnyOfIntDoubleOtherExtension.fromJson(json), equals(object)); object = ( - $double: null, - $int: 361, + $num: 361, string: null, ); @@ -107,8 +99,7 @@ void main() { expect(AnyOfIntDoubleOtherExtension.fromJson(json)..validateAnyOf(), equals(object)); object = ( - $double: null, - $int: null, + $num: null, string: 'string', ); diff --git a/packages/dynamite/dynamite_end_to_end_test/test/one_of_test.dart b/packages/dynamite/dynamite_end_to_end_test/test/one_of_test.dart index b6c41e9f..8e22d781 100644 --- a/packages/dynamite/dynamite_end_to_end_test/test/one_of_test.dart +++ b/packages/dynamite/dynamite_end_to_end_test/test/one_of_test.dart @@ -62,31 +62,26 @@ void main() { }); test('OneOfIntDouble', () { - OneOfIntDouble object = ( - $double: 0.5971645863260784, - $int: null, - ); + Object? object = 0.5971645863260784; - Object? json = 0.5971645863260784; + expect(object, isA()); - expect(object.toJson(), equals(json)); - expect(OneOfIntDoubleExtension.fromJson(json), equals(object)); + object = 361; + expect(object, isA()); + }); - object = ( - $double: null, - $int: 361, - ); + test('OneOfIntDoubleNum', () { + Object? object = 0.6748612915546136; - json = 361; + expect(object, isA()); - expect(object.toJson(), equals(json)); - expect(OneOfIntDoubleExtension.fromJson(json), equals(object)); + object = 769; + expect(object, isA()); }); test('OneOfIntDoubleOther', () { OneOfIntDoubleOther object = ( - $double: 0.5971645863260784, - $int: null, + $num: 0.5971645863260784, string: null, ); @@ -96,8 +91,7 @@ void main() { expect(OneOfIntDoubleOtherExtension.fromJson(json), equals(object)); object = ( - $double: null, - $int: 361, + $num: 361, string: null, ); @@ -107,8 +101,7 @@ void main() { expect(OneOfIntDoubleOtherExtension.fromJson(json), equals(object)); object = ( - $double: null, - $int: null, + $num: null, string: 'string', ); diff --git a/packages/neon/neon/lib/src/pages/account_settings.dart b/packages/neon/neon/lib/src/pages/account_settings.dart index 364869ba..9a3de182 100644 --- a/packages/neon/neon/lib/src/pages/account_settings.dart +++ b/packages/neon/neon/lib/src/pages/account_settings.dart @@ -103,10 +103,9 @@ class AccountSettingsPage extends StatelessWidget { double? value; Widget? subtitle; if (userDetails.hasData) { - final quotaRelative = - userDetails.data?.quota.relative?.$int ?? userDetails.data?.quota.relative?.$double ?? 0; - final quotaTotal = userDetails.data?.quota.total?.$int ?? userDetails.data?.quota.total?.$double ?? 0; - final quotaUsed = userDetails.data?.quota.used?.$int ?? userDetails.data?.quota.used?.$double ?? 0; + final quotaRelative = userDetails.data?.quota.relative ?? 0; + final quotaTotal = userDetails.data?.quota.total ?? 0; + final quotaUsed = userDetails.data?.quota.used ?? 0; value = quotaRelative / 100; subtitle = Text( diff --git a/packages/nextcloud/lib/src/api/files_sharing.openapi.dart b/packages/nextcloud/lib/src/api/files_sharing.openapi.dart index ea71c106..55290769 100644 --- a/packages/nextcloud/lib/src/api/files_sharing.openapi.dart +++ b/packages/nextcloud/lib/src/api/files_sharing.openapi.dart @@ -4851,117 +4851,9 @@ abstract class Capabilities implements CapabilitiesInterface, Built get serializer => _$capabilitiesSerializer; } -typedef ShareInfo_Size = ({int? $int, double? $double}); +typedef ShareInfo_Size = num; -extension ShareInfo_SizeExtension on ShareInfo_Size { - List get _values => [$int, $double]; - void validateOneOf() => dynamite_utils.validateOneOf(_values); - void validateAnyOf() => dynamite_utils.validateAnyOf(_values); - static Serializer get serializer => const _$ShareInfo_SizeSerializer(); - static ShareInfo_Size fromJson(final Object? json) => _jsonSerializers.deserializeWith(serializer, json)!; - Object? toJson() => _jsonSerializers.serializeWith(serializer, this); -} - -class _$ShareInfo_SizeSerializer implements PrimitiveSerializer { - const _$ShareInfo_SizeSerializer(); - - @override - Iterable get types => const [ShareInfo_Size]; - - @override - String get wireName => 'ShareInfo_Size'; - - @override - Object serialize( - final Serializers serializers, - final ShareInfo_Size object, { - final FullType specifiedType = FullType.unspecified, - }) { - dynamic value; - value = object.$int; - if (value != null) { - return _jsonSerializers.serialize(value, specifiedType: const FullType(int))!; - } - value = object.$double; - if (value != null) { - return _jsonSerializers.serialize(value, specifiedType: const FullType(double))!; - } // Should not be possible after validation. - throw StateError('Tried to serialize without any value.'); - } - - @override - ShareInfo_Size deserialize( - final Serializers serializers, - final Object data, { - final FullType specifiedType = FullType.unspecified, - }) { - int? $int; - try { - $int = _jsonSerializers.deserialize(data, specifiedType: const FullType(int))! as int; - } catch (_) {} - double? $double; - try { - $double = _jsonSerializers.deserialize(data, specifiedType: const FullType(double))! as double; - } catch (_) {} - return ($int: $int, $double: $double); - } -} - -typedef Share_ItemSize = ({double? $double, int? $int}); - -extension Share_ItemSizeExtension on Share_ItemSize { - List get _values => [$double, $int]; - void validateOneOf() => dynamite_utils.validateOneOf(_values); - void validateAnyOf() => dynamite_utils.validateAnyOf(_values); - static Serializer get serializer => const _$Share_ItemSizeSerializer(); - static Share_ItemSize fromJson(final Object? json) => _jsonSerializers.deserializeWith(serializer, json)!; - Object? toJson() => _jsonSerializers.serializeWith(serializer, this); -} - -class _$Share_ItemSizeSerializer implements PrimitiveSerializer { - const _$Share_ItemSizeSerializer(); - - @override - Iterable get types => const [Share_ItemSize]; - - @override - String get wireName => 'Share_ItemSize'; - - @override - Object serialize( - final Serializers serializers, - final Share_ItemSize object, { - final FullType specifiedType = FullType.unspecified, - }) { - dynamic value; - value = object.$double; - if (value != null) { - return _jsonSerializers.serialize(value, specifiedType: const FullType(double))!; - } - value = object.$int; - if (value != null) { - return _jsonSerializers.serialize(value, specifiedType: const FullType(int))!; - } // Should not be possible after validation. - throw StateError('Tried to serialize without any value.'); - } - - @override - Share_ItemSize deserialize( - final Serializers serializers, - final Object data, { - final FullType specifiedType = FullType.unspecified, - }) { - double? $double; - try { - $double = _jsonSerializers.deserialize(data, specifiedType: const FullType(double))! as double; - } catch (_) {} - int? $int; - try { - $int = _jsonSerializers.deserialize(data, specifiedType: const FullType(int))! as int; - } catch (_) {} - return ($double: $double, $int: $int); - } -} +typedef Share_ItemSize = num; typedef ShareesapiSearchShareType = ({int? $int, BuiltList? builtListInt}); @@ -5172,7 +5064,6 @@ final Serializers _serializers = (Serializers().toBuilder() ..add(RemoteUnshareResponseApplicationJson_Ocs.serializer) ..addBuilderFactory(const FullType(ShareInfo), ShareInfo.new) ..add(ShareInfo.serializer) - ..add(ShareInfo_SizeExtension.serializer) ..addBuilderFactory( const FullType(BuiltMap, [FullType(String), FullType(JsonObject)]), MapBuilder.new, @@ -5195,7 +5086,6 @@ final Serializers _serializers = (Serializers().toBuilder() ..add(ShareapiGetSharesResponseApplicationJson_Ocs.serializer) ..addBuilderFactory(const FullType(Share), Share.new) ..add(Share.serializer) - ..add(Share_ItemSizeExtension.serializer) ..add(Share_ItemType.serializer) ..addBuilderFactory(const FullType(Share_Status), Share_Status.new) ..add(Share_Status.serializer) diff --git a/packages/nextcloud/lib/src/api/files_sharing.openapi.g.dart b/packages/nextcloud/lib/src/api/files_sharing.openapi.g.dart index 1627ea77..20d5d1ac 100644 --- a/packages/nextcloud/lib/src/api/files_sharing.openapi.g.dart +++ b/packages/nextcloud/lib/src/api/files_sharing.openapi.g.dart @@ -1267,7 +1267,7 @@ class _$ShareInfoSerializer implements StructuredSerializer { 'mimetype', serializers.serialize(object.mimetype, specifiedType: const FullType(String)), 'size', - serializers.serialize(object.size, specifiedType: const FullType(ShareInfo_Size)), + serializers.serialize(object.size, specifiedType: const FullType(num)), 'type', serializers.serialize(object.type, specifiedType: const FullType(String)), 'etag', @@ -1316,8 +1316,7 @@ class _$ShareInfoSerializer implements StructuredSerializer { result.mimetype = serializers.deserialize(value, specifiedType: const FullType(String))! as String; break; case 'size': - result.size = - serializers.deserialize(value, specifiedType: const FullType(ShareInfo_Size))! as ShareInfo_Size; + result.size = serializers.deserialize(value, specifiedType: const FullType(num))! as num; break; case 'type': result.type = serializers.deserialize(value, specifiedType: const FullType(String))! as String; @@ -1454,7 +1453,7 @@ class _$ShareSerializer implements StructuredSerializer { 'item_mtime', serializers.serialize(object.itemMtime, specifiedType: const FullType(int)), 'item_size', - serializers.serialize(object.itemSize, specifiedType: const FullType(Share_ItemSize)), + serializers.serialize(object.itemSize, specifiedType: const FullType(num)), 'item_source', serializers.serialize(object.itemSource, specifiedType: const FullType(int)), 'item_type', @@ -1637,8 +1636,7 @@ class _$ShareSerializer implements StructuredSerializer { result.itemPermissions = serializers.deserialize(value, specifiedType: const FullType(int)) as int?; break; case 'item_size': - result.itemSize = - serializers.deserialize(value, specifiedType: const FullType(Share_ItemSize))! as Share_ItemSize; + result.itemSize = serializers.deserialize(value, specifiedType: const FullType(num))! as num; break; case 'item_source': result.itemSource = serializers.deserialize(value, specifiedType: const FullType(int))! as int; @@ -7374,8 +7372,8 @@ abstract mixin class ShareInfoInterfaceBuilder { String? get mimetype; set mimetype(String? mimetype); - ShareInfo_Size? get size; - set size(ShareInfo_Size? size); + num? get size; + set size(num? size); String? get type; set type(String? type); @@ -7401,7 +7399,7 @@ class _$ShareInfo extends ShareInfo { @override final String mimetype; @override - final ShareInfo_Size size; + final num size; @override final String type; @override @@ -7443,7 +7441,6 @@ class _$ShareInfo extends ShareInfo { @override bool operator ==(Object other) { if (identical(other, this)) return true; - final dynamic _$dynamicOther = other; return other is ShareInfo && id == other.id && parentId == other.parentId && @@ -7451,7 +7448,7 @@ class _$ShareInfo extends ShareInfo { name == other.name && permissions == other.permissions && mimetype == other.mimetype && - size == _$dynamicOther.size && + size == other.size && type == other.type && etag == other.etag && children == other.children; @@ -7518,9 +7515,9 @@ class ShareInfoBuilder implements Builder, ShareInf String? get mimetype => _$this._mimetype; set mimetype(covariant String? mimetype) => _$this._mimetype = mimetype; - ShareInfo_Size? _size; - ShareInfo_Size? get size => _$this._size; - set size(covariant ShareInfo_Size? size) => _$this._size = size; + num? _size; + num? get size => _$this._size; + set size(covariant num? size) => _$this._size = size; String? _type; String? get type => _$this._type; @@ -7767,8 +7764,8 @@ abstract mixin class ShareInterfaceBuilder { int? get itemPermissions; set itemPermissions(int? itemPermissions); - Share_ItemSize? get itemSize; - set itemSize(Share_ItemSize? itemSize); + num? get itemSize; + set itemSize(num? itemSize); int? get itemSource; set itemSource(int? itemSource); @@ -7879,7 +7876,7 @@ class _$Share extends Share { @override final int? itemPermissions; @override - final Share_ItemSize itemSize; + final num itemSize; @override final int itemSource; @override @@ -8014,7 +8011,6 @@ class _$Share extends Share { @override bool operator ==(Object other) { if (identical(other, this)) return true; - final dynamic _$dynamicOther = other; return other is Share && attributes == other.attributes && canDelete == other.canDelete && @@ -8030,7 +8026,7 @@ class _$Share extends Share { id == other.id && itemMtime == other.itemMtime && itemPermissions == other.itemPermissions && - itemSize == _$dynamicOther.itemSize && + itemSize == other.itemSize && itemSource == other.itemSource && itemType == other.itemType && label == other.label && @@ -8215,9 +8211,9 @@ class ShareBuilder implements Builder, ShareInterfaceBuilde int? get itemPermissions => _$this._itemPermissions; set itemPermissions(covariant int? itemPermissions) => _$this._itemPermissions = itemPermissions; - Share_ItemSize? _itemSize; - Share_ItemSize? get itemSize => _$this._itemSize; - set itemSize(covariant Share_ItemSize? itemSize) => _$this._itemSize = itemSize; + num? _itemSize; + num? get itemSize => _$this._itemSize; + set itemSize(covariant num? itemSize) => _$this._itemSize = itemSize; int? _itemSource; int? get itemSource => _$this._itemSource; diff --git a/packages/nextcloud/lib/src/api/provisioning_api.openapi.dart b/packages/nextcloud/lib/src/api/provisioning_api.openapi.dart index c2bfd0a9..5bf03507 100644 --- a/packages/nextcloud/lib/src/api/provisioning_api.openapi.dart +++ b/packages/nextcloud/lib/src/api/provisioning_api.openapi.dart @@ -8184,66 +8184,12 @@ class _$GroupDetails_DisabledSerializer implements PrimitiveSerializer get _values => [$double, $int]; - void validateOneOf() => dynamite_utils.validateOneOf(_values); - void validateAnyOf() => dynamite_utils.validateAnyOf(_values); - static Serializer get serializer => const _$UserDetailsQuota_FreeSerializer(); - static UserDetailsQuota_Free fromJson(final Object? json) => _jsonSerializers.deserializeWith(serializer, json)!; - Object? toJson() => _jsonSerializers.serializeWith(serializer, this); -} - -class _$UserDetailsQuota_FreeSerializer implements PrimitiveSerializer { - const _$UserDetailsQuota_FreeSerializer(); - - @override - Iterable get types => const [UserDetailsQuota_Free]; - - @override - String get wireName => 'UserDetailsQuota_Free'; - - @override - Object serialize( - final Serializers serializers, - final UserDetailsQuota_Free object, { - final FullType specifiedType = FullType.unspecified, - }) { - dynamic value; - value = object.$double; - if (value != null) { - return _jsonSerializers.serialize(value, specifiedType: const FullType(double))!; - } - value = object.$int; - if (value != null) { - return _jsonSerializers.serialize(value, specifiedType: const FullType(int))!; - } // Should not be possible after validation. - throw StateError('Tried to serialize without any value.'); - } - - @override - UserDetailsQuota_Free deserialize( - final Serializers serializers, - final Object data, { - final FullType specifiedType = FullType.unspecified, - }) { - double? $double; - try { - $double = _jsonSerializers.deserialize(data, specifiedType: const FullType(double))! as double; - } catch (_) {} - int? $int; - try { - $int = _jsonSerializers.deserialize(data, specifiedType: const FullType(int))! as int; - } catch (_) {} - return ($double: $double, $int: $int); - } -} - -typedef UserDetailsQuota_Quota = ({double? $double, int? $int, String? string}); +typedef UserDetailsQuota_Quota = ({num? $num, String? string}); extension UserDetailsQuota_QuotaExtension on UserDetailsQuota_Quota { - List get _values => [$double, $int, string]; + List get _values => [$num, string]; void validateOneOf() => dynamite_utils.validateOneOf(_values); void validateAnyOf() => dynamite_utils.validateAnyOf(_values); static Serializer get serializer => const _$UserDetailsQuota_QuotaSerializer(); @@ -8267,13 +8213,9 @@ class _$UserDetailsQuota_QuotaSerializer implements PrimitiveSerializer get _values => [$double, $int]; - void validateOneOf() => dynamite_utils.validateOneOf(_values); - void validateAnyOf() => dynamite_utils.validateAnyOf(_values); - static Serializer get serializer => const _$UserDetailsQuota_RelativeSerializer(); - static UserDetailsQuota_Relative fromJson(final Object? json) => _jsonSerializers.deserializeWith(serializer, json)!; - Object? toJson() => _jsonSerializers.serializeWith(serializer, this); -} - -class _$UserDetailsQuota_RelativeSerializer implements PrimitiveSerializer { - const _$UserDetailsQuota_RelativeSerializer(); - - @override - Iterable get types => const [UserDetailsQuota_Relative]; - - @override - String get wireName => 'UserDetailsQuota_Relative'; - - @override - Object serialize( - final Serializers serializers, - final UserDetailsQuota_Relative object, { - final FullType specifiedType = FullType.unspecified, - }) { - dynamic value; - value = object.$double; - if (value != null) { - return _jsonSerializers.serialize(value, specifiedType: const FullType(double))!; - } - value = object.$int; - if (value != null) { - return _jsonSerializers.serialize(value, specifiedType: const FullType(int))!; - } // Should not be possible after validation. - throw StateError('Tried to serialize without any value.'); - } - - @override - UserDetailsQuota_Relative deserialize( - final Serializers serializers, - final Object data, { - final FullType specifiedType = FullType.unspecified, - }) { - double? $double; - try { - $double = _jsonSerializers.deserialize(data, specifiedType: const FullType(double))! as double; - } catch (_) {} - int? $int; - try { - $int = _jsonSerializers.deserialize(data, specifiedType: const FullType(int))! as int; - } catch (_) {} - return ($double: $double, $int: $int); - } -} - -typedef UserDetailsQuota_Total = ({double? $double, int? $int}); - -extension UserDetailsQuota_TotalExtension on UserDetailsQuota_Total { - List get _values => [$double, $int]; - void validateOneOf() => dynamite_utils.validateOneOf(_values); - void validateAnyOf() => dynamite_utils.validateAnyOf(_values); - static Serializer get serializer => const _$UserDetailsQuota_TotalSerializer(); - static UserDetailsQuota_Total fromJson(final Object? json) => _jsonSerializers.deserializeWith(serializer, json)!; - Object? toJson() => _jsonSerializers.serializeWith(serializer, this); -} - -class _$UserDetailsQuota_TotalSerializer implements PrimitiveSerializer { - const _$UserDetailsQuota_TotalSerializer(); - - @override - Iterable get types => const [UserDetailsQuota_Total]; - - @override - String get wireName => 'UserDetailsQuota_Total'; - - @override - Object serialize( - final Serializers serializers, - final UserDetailsQuota_Total object, { - final FullType specifiedType = FullType.unspecified, - }) { - dynamic value; - value = object.$double; - if (value != null) { - return _jsonSerializers.serialize(value, specifiedType: const FullType(double))!; - } - value = object.$int; - if (value != null) { - return _jsonSerializers.serialize(value, specifiedType: const FullType(int))!; - } // Should not be possible after validation. - throw StateError('Tried to serialize without any value.'); - } - - @override - UserDetailsQuota_Total deserialize( - final Serializers serializers, - final Object data, { - final FullType specifiedType = FullType.unspecified, - }) { - double? $double; - try { - $double = _jsonSerializers.deserialize(data, specifiedType: const FullType(double))! as double; - } catch (_) {} - int? $int; - try { - $int = _jsonSerializers.deserialize(data, specifiedType: const FullType(int))! as int; - } catch (_) {} - return ($double: $double, $int: $int); + return ($num: $num, string: string); } } -typedef UserDetailsQuota_Used = ({double? $double, int? $int}); +typedef UserDetailsQuota_Relative = num; -extension UserDetailsQuota_UsedExtension on UserDetailsQuota_Used { - List get _values => [$double, $int]; - void validateOneOf() => dynamite_utils.validateOneOf(_values); - void validateAnyOf() => dynamite_utils.validateAnyOf(_values); - static Serializer get serializer => const _$UserDetailsQuota_UsedSerializer(); - static UserDetailsQuota_Used fromJson(final Object? json) => _jsonSerializers.deserializeWith(serializer, json)!; - Object? toJson() => _jsonSerializers.serializeWith(serializer, this); -} - -class _$UserDetailsQuota_UsedSerializer implements PrimitiveSerializer { - const _$UserDetailsQuota_UsedSerializer(); - - @override - Iterable get types => const [UserDetailsQuota_Used]; +typedef UserDetailsQuota_Total = num; - @override - String get wireName => 'UserDetailsQuota_Used'; - - @override - Object serialize( - final Serializers serializers, - final UserDetailsQuota_Used object, { - final FullType specifiedType = FullType.unspecified, - }) { - dynamic value; - value = object.$double; - if (value != null) { - return _jsonSerializers.serialize(value, specifiedType: const FullType(double))!; - } - value = object.$int; - if (value != null) { - return _jsonSerializers.serialize(value, specifiedType: const FullType(int))!; - } // Should not be possible after validation. - throw StateError('Tried to serialize without any value.'); - } - - @override - UserDetailsQuota_Used deserialize( - final Serializers serializers, - final Object data, { - final FullType specifiedType = FullType.unspecified, - }) { - double? $double; - try { - $double = _jsonSerializers.deserialize(data, specifiedType: const FullType(double))! as double; - } catch (_) {} - int? $int; - try { - $int = _jsonSerializers.deserialize(data, specifiedType: const FullType(int))! as int; - } catch (_) {} - return ($double: $double, $int: $int); - } -} +typedef UserDetailsQuota_Used = num; typedef GroupsGetGroupUsersDetailsResponseApplicationJson_Ocs_Data_Users = ({ UserDetails? userDetails, @@ -8882,11 +8658,7 @@ final Serializers _serializers = (Serializers().toBuilder() ..add(UserDetails_BackendCapabilities.serializer) ..addBuilderFactory(const FullType(UserDetailsQuota), UserDetailsQuota.new) ..add(UserDetailsQuota.serializer) - ..add(UserDetailsQuota_FreeExtension.serializer) ..add(UserDetailsQuota_QuotaExtension.serializer) - ..add(UserDetailsQuota_RelativeExtension.serializer) - ..add(UserDetailsQuota_TotalExtension.serializer) - ..add(UserDetailsQuota_UsedExtension.serializer) ..addBuilderFactory( const FullType(GroupsGetGroupUsersDetailsResponseApplicationJson_Ocs_Data_Users1), GroupsGetGroupUsersDetailsResponseApplicationJson_Ocs_Data_Users1.new, diff --git a/packages/nextcloud/lib/src/api/provisioning_api.openapi.g.dart b/packages/nextcloud/lib/src/api/provisioning_api.openapi.g.dart index 0c0359cd..076207a1 100644 --- a/packages/nextcloud/lib/src/api/provisioning_api.openapi.g.dart +++ b/packages/nextcloud/lib/src/api/provisioning_api.openapi.g.dart @@ -2304,7 +2304,7 @@ class _$UserDetailsQuotaSerializer implements StructuredSerializer (UserDetailsQuotaBuilder()..update(updates))._build(); @@ -10830,11 +10826,11 @@ class _$UserDetailsQuota extends UserDetailsQuota { if (identical(other, this)) return true; final dynamic _$dynamicOther = other; return other is UserDetailsQuota && - free == _$dynamicOther.free && + free == other.free && quota == _$dynamicOther.quota && - relative == _$dynamicOther.relative && - total == _$dynamicOther.total && - used == _$dynamicOther.used; + relative == other.relative && + total == other.total && + used == other.used; } @override @@ -10865,25 +10861,25 @@ class UserDetailsQuotaBuilder implements Builder, UserDetailsQuotaInterfaceBuilder { _$UserDetailsQuota? _$v; - UserDetailsQuota_Free? _free; - UserDetailsQuota_Free? get free => _$this._free; - set free(covariant UserDetailsQuota_Free? free) => _$this._free = free; + num? _free; + num? get free => _$this._free; + set free(covariant num? free) => _$this._free = free; UserDetailsQuota_Quota? _quota; UserDetailsQuota_Quota? get quota => _$this._quota; set quota(covariant UserDetailsQuota_Quota? quota) => _$this._quota = quota; - UserDetailsQuota_Relative? _relative; - UserDetailsQuota_Relative? get relative => _$this._relative; - set relative(covariant UserDetailsQuota_Relative? relative) => _$this._relative = relative; + num? _relative; + num? get relative => _$this._relative; + set relative(covariant num? relative) => _$this._relative = relative; - UserDetailsQuota_Total? _total; - UserDetailsQuota_Total? get total => _$this._total; - set total(covariant UserDetailsQuota_Total? total) => _$this._total = total; + num? _total; + num? get total => _$this._total; + set total(covariant num? total) => _$this._total = total; - UserDetailsQuota_Used? _used; - UserDetailsQuota_Used? get used => _$this._used; - set used(covariant UserDetailsQuota_Used? used) => _$this._used = used; + num? _used; + num? get used => _$this._used; + set used(covariant num? used) => _$this._used = used; UserDetailsQuotaBuilder();