1
0
mirror of https://github.com/immich-app/immich.git synced 2025-08-10 23:22:22 +02:00

refactor: library type (#9525)

This commit is contained in:
Jason Rasmussen
2024-05-20 18:09:10 -04:00
committed by GitHub
parent 4353153fe6
commit 84d824d6a7
66 changed files with 183 additions and 984 deletions

View File

@@ -134,7 +134,6 @@ part 'model/job_settings_dto.dart';
part 'model/job_status_dto.dart';
part 'model/library_response_dto.dart';
part 'model/library_stats_response_dto.dart';
part 'model/library_type.dart';
part 'model/log_level.dart';
part 'model/login_credential_dto.dart';
part 'model/login_response_dto.dart';

View File

@@ -977,12 +977,10 @@ class AssetApi {
///
/// * [bool] isVisible:
///
/// * [String] libraryId:
///
/// * [MultipartFile] livePhotoData:
///
/// * [MultipartFile] sidecarData:
Future<Response> uploadFileWithHttpInfo(MultipartFile assetData, String deviceAssetId, String deviceId, DateTime fileCreatedAt, DateTime fileModifiedAt, { String? key, String? xImmichChecksum, String? duration, bool? isArchived, bool? isFavorite, bool? isOffline, bool? isVisible, String? libraryId, MultipartFile? livePhotoData, MultipartFile? sidecarData, }) async {
Future<Response> uploadFileWithHttpInfo(MultipartFile assetData, String deviceAssetId, String deviceId, DateTime fileCreatedAt, DateTime fileModifiedAt, { String? key, String? xImmichChecksum, String? duration, bool? isArchived, bool? isFavorite, bool? isOffline, bool? isVisible, MultipartFile? livePhotoData, MultipartFile? sidecarData, }) async {
// ignore: prefer_const_declarations
final path = r'/asset/upload';
@@ -1046,10 +1044,6 @@ class AssetApi {
hasFields = true;
mp.fields[r'isVisible'] = parameterToString(isVisible);
}
if (libraryId != null) {
hasFields = true;
mp.fields[r'libraryId'] = parameterToString(libraryId);
}
if (livePhotoData != null) {
hasFields = true;
mp.fields[r'livePhotoData'] = livePhotoData.field;
@@ -1102,13 +1096,11 @@ class AssetApi {
///
/// * [bool] isVisible:
///
/// * [String] libraryId:
///
/// * [MultipartFile] livePhotoData:
///
/// * [MultipartFile] sidecarData:
Future<AssetFileUploadResponseDto?> uploadFile(MultipartFile assetData, String deviceAssetId, String deviceId, DateTime fileCreatedAt, DateTime fileModifiedAt, { String? key, String? xImmichChecksum, String? duration, bool? isArchived, bool? isFavorite, bool? isOffline, bool? isVisible, String? libraryId, MultipartFile? livePhotoData, MultipartFile? sidecarData, }) async {
final response = await uploadFileWithHttpInfo(assetData, deviceAssetId, deviceId, fileCreatedAt, fileModifiedAt, key: key, xImmichChecksum: xImmichChecksum, duration: duration, isArchived: isArchived, isFavorite: isFavorite, isOffline: isOffline, isVisible: isVisible, libraryId: libraryId, livePhotoData: livePhotoData, sidecarData: sidecarData, );
Future<AssetFileUploadResponseDto?> uploadFile(MultipartFile assetData, String deviceAssetId, String deviceId, DateTime fileCreatedAt, DateTime fileModifiedAt, { String? key, String? xImmichChecksum, String? duration, bool? isArchived, bool? isFavorite, bool? isOffline, bool? isVisible, MultipartFile? livePhotoData, MultipartFile? sidecarData, }) async {
final response = await uploadFileWithHttpInfo(assetData, deviceAssetId, deviceId, fileCreatedAt, fileModifiedAt, key: key, xImmichChecksum: xImmichChecksum, duration: duration, isArchived: isArchived, isFavorite: isFavorite, isOffline: isOffline, isVisible: isVisible, livePhotoData: livePhotoData, sidecarData: sidecarData, );
if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
}

View File

@@ -104,10 +104,7 @@ class LibraryApi {
}
/// Performs an HTTP 'GET /library' operation and returns the [Response].
/// Parameters:
///
/// * [LibraryType] type:
Future<Response> getAllLibrariesWithHttpInfo({ LibraryType? type, }) async {
Future<Response> getAllLibrariesWithHttpInfo() async {
// ignore: prefer_const_declarations
final path = r'/library';
@@ -118,10 +115,6 @@ class LibraryApi {
final headerParams = <String, String>{};
final formParams = <String, String>{};
if (type != null) {
queryParams.addAll(_queryParams('', 'type', type));
}
const contentTypes = <String>[];
@@ -136,11 +129,8 @@ class LibraryApi {
);
}
/// Parameters:
///
/// * [LibraryType] type:
Future<List<LibraryResponseDto>?> getAllLibraries({ LibraryType? type, }) async {
final response = await getAllLibrariesWithHttpInfo( type: type, );
Future<List<LibraryResponseDto>?> getAllLibraries() async {
final response = await getAllLibrariesWithHttpInfo();
if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
}

View File

@@ -336,8 +336,6 @@ class ApiClient {
return LibraryResponseDto.fromJson(value);
case 'LibraryStatsResponseDto':
return LibraryStatsResponseDto.fromJson(value);
case 'LibraryType':
return LibraryTypeTypeTransformer().decode(value);
case 'LogLevel':
return LogLevelTypeTransformer().decode(value);
case 'LoginCredentialDto':

View File

@@ -91,9 +91,6 @@ String parameterToString(dynamic value) {
if (value is JobName) {
return JobNameTypeTransformer().encode(value).toString();
}
if (value is LibraryType) {
return LibraryTypeTypeTransformer().encode(value).toString();
}
if (value is LogLevel) {
return LogLevelTypeTransformer().encode(value).toString();
}

View File

@@ -29,7 +29,7 @@ class AssetResponseDto {
required this.isOffline,
this.isReadOnly,
required this.isTrashed,
required this.libraryId,
this.libraryId,
this.livePhotoVideoId,
required this.localDateTime,
required this.originalFileName,
@@ -101,7 +101,8 @@ class AssetResponseDto {
bool isTrashed;
String libraryId;
/// This property was deprecated in v1.106.0
String? libraryId;
String? livePhotoVideoId;
@@ -202,7 +203,7 @@ class AssetResponseDto {
(isOffline.hashCode) +
(isReadOnly == null ? 0 : isReadOnly!.hashCode) +
(isTrashed.hashCode) +
(libraryId.hashCode) +
(libraryId == null ? 0 : libraryId!.hashCode) +
(livePhotoVideoId == null ? 0 : livePhotoVideoId!.hashCode) +
(localDateTime.hashCode) +
(originalFileName.hashCode) +
@@ -257,7 +258,11 @@ class AssetResponseDto {
// json[r'isReadOnly'] = null;
}
json[r'isTrashed'] = this.isTrashed;
if (this.libraryId != null) {
json[r'libraryId'] = this.libraryId;
} else {
// json[r'libraryId'] = null;
}
if (this.livePhotoVideoId != null) {
json[r'livePhotoVideoId'] = this.livePhotoVideoId;
} else {
@@ -325,7 +330,7 @@ class AssetResponseDto {
isOffline: mapValueOfType<bool>(json, r'isOffline')!,
isReadOnly: mapValueOfType<bool>(json, r'isReadOnly'),
isTrashed: mapValueOfType<bool>(json, r'isTrashed')!,
libraryId: mapValueOfType<String>(json, r'libraryId')!,
libraryId: mapValueOfType<String>(json, r'libraryId'),
livePhotoVideoId: mapValueOfType<String>(json, r'livePhotoVideoId'),
localDateTime: mapDateTime(json, r'localDateTime', r'')!,
originalFileName: mapValueOfType<String>(json, r'originalFileName')!,
@@ -401,7 +406,6 @@ class AssetResponseDto {
'isFavorite',
'isOffline',
'isTrashed',
'libraryId',
'localDateTime',
'originalFileName',
'originalPath',

View File

@@ -17,7 +17,6 @@ class CreateLibraryDto {
this.importPaths = const [],
this.name,
required this.ownerId,
required this.type,
});
List<String> exclusionPatterns;
@@ -34,15 +33,12 @@ class CreateLibraryDto {
String ownerId;
LibraryType type;
@override
bool operator ==(Object other) => identical(this, other) || other is CreateLibraryDto &&
_deepEquality.equals(other.exclusionPatterns, exclusionPatterns) &&
_deepEquality.equals(other.importPaths, importPaths) &&
other.name == name &&
other.ownerId == ownerId &&
other.type == type;
other.ownerId == ownerId;
@override
int get hashCode =>
@@ -50,11 +46,10 @@ class CreateLibraryDto {
(exclusionPatterns.hashCode) +
(importPaths.hashCode) +
(name == null ? 0 : name!.hashCode) +
(ownerId.hashCode) +
(type.hashCode);
(ownerId.hashCode);
@override
String toString() => 'CreateLibraryDto[exclusionPatterns=$exclusionPatterns, importPaths=$importPaths, name=$name, ownerId=$ownerId, type=$type]';
String toString() => 'CreateLibraryDto[exclusionPatterns=$exclusionPatterns, importPaths=$importPaths, name=$name, ownerId=$ownerId]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
@@ -66,7 +61,6 @@ class CreateLibraryDto {
// json[r'name'] = null;
}
json[r'ownerId'] = this.ownerId;
json[r'type'] = this.type;
return json;
}
@@ -86,7 +80,6 @@ class CreateLibraryDto {
: const [],
name: mapValueOfType<String>(json, r'name'),
ownerId: mapValueOfType<String>(json, r'ownerId')!,
type: LibraryType.fromJson(json[r'type'])!,
);
}
return null;
@@ -135,7 +128,6 @@ class CreateLibraryDto {
/// The list of required keys that must be present in a JSON.
static const requiredKeys = <String>{
'ownerId',
'type',
};
}

View File

@@ -21,7 +21,6 @@ class LibraryResponseDto {
required this.name,
required this.ownerId,
required this.refreshedAt,
required this.type,
required this.updatedAt,
});
@@ -41,8 +40,6 @@ class LibraryResponseDto {
DateTime? refreshedAt;
LibraryType type;
DateTime updatedAt;
@override
@@ -55,7 +52,6 @@ class LibraryResponseDto {
other.name == name &&
other.ownerId == ownerId &&
other.refreshedAt == refreshedAt &&
other.type == type &&
other.updatedAt == updatedAt;
@override
@@ -69,11 +65,10 @@ class LibraryResponseDto {
(name.hashCode) +
(ownerId.hashCode) +
(refreshedAt == null ? 0 : refreshedAt!.hashCode) +
(type.hashCode) +
(updatedAt.hashCode);
@override
String toString() => 'LibraryResponseDto[assetCount=$assetCount, createdAt=$createdAt, exclusionPatterns=$exclusionPatterns, id=$id, importPaths=$importPaths, name=$name, ownerId=$ownerId, refreshedAt=$refreshedAt, type=$type, updatedAt=$updatedAt]';
String toString() => 'LibraryResponseDto[assetCount=$assetCount, createdAt=$createdAt, exclusionPatterns=$exclusionPatterns, id=$id, importPaths=$importPaths, name=$name, ownerId=$ownerId, refreshedAt=$refreshedAt, updatedAt=$updatedAt]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
@@ -89,7 +84,6 @@ class LibraryResponseDto {
} else {
// json[r'refreshedAt'] = null;
}
json[r'type'] = this.type;
json[r'updatedAt'] = this.updatedAt.toUtc().toIso8601String();
return json;
}
@@ -114,7 +108,6 @@ class LibraryResponseDto {
name: mapValueOfType<String>(json, r'name')!,
ownerId: mapValueOfType<String>(json, r'ownerId')!,
refreshedAt: mapDateTime(json, r'refreshedAt', r''),
type: LibraryType.fromJson(json[r'type'])!,
updatedAt: mapDateTime(json, r'updatedAt', r'')!,
);
}
@@ -171,7 +164,6 @@ class LibraryResponseDto {
'name',
'ownerId',
'refreshedAt',
'type',
'updatedAt',
};
}

View File

@@ -1,85 +0,0 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
// @dart=2.18
// ignore_for_file: unused_element, unused_import
// ignore_for_file: always_put_required_named_parameters_first
// ignore_for_file: constant_identifier_names
// ignore_for_file: lines_longer_than_80_chars
part of openapi.api;
class LibraryType {
/// Instantiate a new enum with the provided [value].
const LibraryType._(this.value);
/// The underlying value of this enum member.
final String value;
@override
String toString() => value;
String toJson() => value;
static const UPLOAD = LibraryType._(r'UPLOAD');
static const EXTERNAL = LibraryType._(r'EXTERNAL');
/// List of all possible values in this [enum][LibraryType].
static const values = <LibraryType>[
UPLOAD,
EXTERNAL,
];
static LibraryType? fromJson(dynamic value) => LibraryTypeTypeTransformer().decode(value);
static List<LibraryType> listFromJson(dynamic json, {bool growable = false,}) {
final result = <LibraryType>[];
if (json is List && json.isNotEmpty) {
for (final row in json) {
final value = LibraryType.fromJson(row);
if (value != null) {
result.add(value);
}
}
}
return result.toList(growable: growable);
}
}
/// Transformation class that can [encode] an instance of [LibraryType] to String,
/// and [decode] dynamic data back to [LibraryType].
class LibraryTypeTypeTransformer {
factory LibraryTypeTypeTransformer() => _instance ??= const LibraryTypeTypeTransformer._();
const LibraryTypeTypeTransformer._();
String encode(LibraryType data) => data.value;
/// Decodes a [dynamic value][data] to a LibraryType.
///
/// If [allowNull] is true and the [dynamic value][data] cannot be decoded successfully,
/// then null is returned. However, if [allowNull] is false and the [dynamic value][data]
/// cannot be decoded successfully, then an [UnimplementedError] is thrown.
///
/// The [allowNull] is very handy when an API changes and a new enum value is added or removed,
/// and users are still using an old app with the old code.
LibraryType? decode(dynamic data, {bool allowNull = true}) {
if (data != null) {
switch (data) {
case r'UPLOAD': return LibraryType.UPLOAD;
case r'EXTERNAL': return LibraryType.EXTERNAL;
default:
if (!allowNull) {
throw ArgumentError('Unknown enum value to decode: $data');
}
}
}
return null;
}
/// Singleton [LibraryTypeTypeTransformer] instance.
static LibraryTypeTypeTransformer? _instance;
}