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

feat: tags (#11980)

* feat: tags

* fix: folder tree icons

* navigate to tag from detail panel

* delete tag

* Tag position and add tag button

* Tag asset in detail panel

* refactor form

* feat: navigate to tag page from clicking on a tag

* feat: delete tags from the tag page

* refactor: moving tag section in detail panel and add + tag button

* feat: tag asset action in detail panel

* refactor add tag form

* fdisable add tag button when there is no selection

* feat: tag bulk endpoint

* feat: tag colors

* chore: clean up

* chore: unit tests

* feat: write tags to sidecar

* Remove tag and auto focus on tag creation form opened

* chore: regenerate migration

* chore: linting

* add color picker to tag edit form

* fix: force render tags timeline on navigating back from asset viewer

* feat: read tags from keywords

* chore: clean up

---------

Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
This commit is contained in:
Jason Rasmussen
2024-08-29 12:14:03 -04:00
committed by GitHub
parent 682adaa334
commit d08a20bd57
68 changed files with 3032 additions and 814 deletions

View File

@@ -120,7 +120,6 @@ part 'model/colorspace.dart';
part 'model/create_album_dto.dart';
part 'model/create_library_dto.dart';
part 'model/create_profile_image_response_dto.dart';
part 'model/create_tag_dto.dart';
part 'model/download_archive_info.dart';
part 'model/download_info_dto.dart';
part 'model/download_response.dart';
@@ -244,8 +243,12 @@ part 'model/system_config_template_storage_option_dto.dart';
part 'model/system_config_theme_dto.dart';
part 'model/system_config_trash_dto.dart';
part 'model/system_config_user_dto.dart';
part 'model/tag_bulk_assets_dto.dart';
part 'model/tag_bulk_assets_response_dto.dart';
part 'model/tag_create_dto.dart';
part 'model/tag_response_dto.dart';
part 'model/tag_type_enum.dart';
part 'model/tag_update_dto.dart';
part 'model/tag_upsert_dto.dart';
part 'model/time_bucket_response_dto.dart';
part 'model/time_bucket_size.dart';
part 'model/tone_mapping.dart';
@@ -256,7 +259,6 @@ part 'model/update_album_user_dto.dart';
part 'model/update_asset_dto.dart';
part 'model/update_library_dto.dart';
part 'model/update_partner_dto.dart';
part 'model/update_tag_dto.dart';
part 'model/usage_by_user_dto.dart';
part 'model/user_admin_create_dto.dart';
part 'model/user_admin_delete_dto.dart';

View File

@@ -16,16 +16,63 @@ class TagsApi {
final ApiClient apiClient;
/// Performs an HTTP 'PUT /tags/assets' operation and returns the [Response].
/// Parameters:
///
/// * [TagBulkAssetsDto] tagBulkAssetsDto (required):
Future<Response> bulkTagAssetsWithHttpInfo(TagBulkAssetsDto tagBulkAssetsDto,) async {
// ignore: prefer_const_declarations
final path = r'/tags/assets';
// ignore: prefer_final_locals
Object? postBody = tagBulkAssetsDto;
final queryParams = <QueryParam>[];
final headerParams = <String, String>{};
final formParams = <String, String>{};
const contentTypes = <String>['application/json'];
return apiClient.invokeAPI(
path,
'PUT',
queryParams,
postBody,
headerParams,
formParams,
contentTypes.isEmpty ? null : contentTypes.first,
);
}
/// Parameters:
///
/// * [TagBulkAssetsDto] tagBulkAssetsDto (required):
Future<TagBulkAssetsResponseDto?> bulkTagAssets(TagBulkAssetsDto tagBulkAssetsDto,) async {
final response = await bulkTagAssetsWithHttpInfo(tagBulkAssetsDto,);
if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
}
// When a remote server returns no body with a status of 204, we shall not decode it.
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
// FormatException when trying to decode an empty string.
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'TagBulkAssetsResponseDto',) as TagBulkAssetsResponseDto;
}
return null;
}
/// Performs an HTTP 'POST /tags' operation and returns the [Response].
/// Parameters:
///
/// * [CreateTagDto] createTagDto (required):
Future<Response> createTagWithHttpInfo(CreateTagDto createTagDto,) async {
/// * [TagCreateDto] tagCreateDto (required):
Future<Response> createTagWithHttpInfo(TagCreateDto tagCreateDto,) async {
// ignore: prefer_const_declarations
final path = r'/tags';
// ignore: prefer_final_locals
Object? postBody = createTagDto;
Object? postBody = tagCreateDto;
final queryParams = <QueryParam>[];
final headerParams = <String, String>{};
@@ -47,9 +94,9 @@ class TagsApi {
/// Parameters:
///
/// * [CreateTagDto] createTagDto (required):
Future<TagResponseDto?> createTag(CreateTagDto createTagDto,) async {
final response = await createTagWithHttpInfo(createTagDto,);
/// * [TagCreateDto] tagCreateDto (required):
Future<TagResponseDto?> createTag(TagCreateDto tagCreateDto,) async {
final response = await createTagWithHttpInfo(tagCreateDto,);
if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
}
@@ -147,57 +194,6 @@ class TagsApi {
return null;
}
/// Performs an HTTP 'GET /tags/{id}/assets' operation and returns the [Response].
/// Parameters:
///
/// * [String] id (required):
Future<Response> getTagAssetsWithHttpInfo(String id,) async {
// ignore: prefer_const_declarations
final path = r'/tags/{id}/assets'
.replaceAll('{id}', id);
// ignore: prefer_final_locals
Object? postBody;
final queryParams = <QueryParam>[];
final headerParams = <String, String>{};
final formParams = <String, String>{};
const contentTypes = <String>[];
return apiClient.invokeAPI(
path,
'GET',
queryParams,
postBody,
headerParams,
formParams,
contentTypes.isEmpty ? null : contentTypes.first,
);
}
/// Parameters:
///
/// * [String] id (required):
Future<List<AssetResponseDto>?> getTagAssets(String id,) async {
final response = await getTagAssetsWithHttpInfo(id,);
if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
}
// When a remote server returns no body with a status of 204, we shall not decode it.
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
// FormatException when trying to decode an empty string.
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
final responseBody = await _decodeBodyBytes(response);
return (await apiClient.deserializeAsync(responseBody, 'List<AssetResponseDto>') as List)
.cast<AssetResponseDto>()
.toList(growable: false);
}
return null;
}
/// Performs an HTTP 'GET /tags/{id}' operation and returns the [Response].
/// Parameters:
///
@@ -251,14 +247,14 @@ class TagsApi {
///
/// * [String] id (required):
///
/// * [AssetIdsDto] assetIdsDto (required):
Future<Response> tagAssetsWithHttpInfo(String id, AssetIdsDto assetIdsDto,) async {
/// * [BulkIdsDto] bulkIdsDto (required):
Future<Response> tagAssetsWithHttpInfo(String id, BulkIdsDto bulkIdsDto,) async {
// ignore: prefer_const_declarations
final path = r'/tags/{id}/assets'
.replaceAll('{id}', id);
// ignore: prefer_final_locals
Object? postBody = assetIdsDto;
Object? postBody = bulkIdsDto;
final queryParams = <QueryParam>[];
final headerParams = <String, String>{};
@@ -282,9 +278,9 @@ class TagsApi {
///
/// * [String] id (required):
///
/// * [AssetIdsDto] assetIdsDto (required):
Future<List<AssetIdsResponseDto>?> tagAssets(String id, AssetIdsDto assetIdsDto,) async {
final response = await tagAssetsWithHttpInfo(id, assetIdsDto,);
/// * [BulkIdsDto] bulkIdsDto (required):
Future<List<BulkIdResponseDto>?> tagAssets(String id, BulkIdsDto bulkIdsDto,) async {
final response = await tagAssetsWithHttpInfo(id, bulkIdsDto,);
if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
}
@@ -293,8 +289,8 @@ class TagsApi {
// FormatException when trying to decode an empty string.
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
final responseBody = await _decodeBodyBytes(response);
return (await apiClient.deserializeAsync(responseBody, 'List<AssetIdsResponseDto>') as List)
.cast<AssetIdsResponseDto>()
return (await apiClient.deserializeAsync(responseBody, 'List<BulkIdResponseDto>') as List)
.cast<BulkIdResponseDto>()
.toList(growable: false);
}
@@ -306,14 +302,14 @@ class TagsApi {
///
/// * [String] id (required):
///
/// * [AssetIdsDto] assetIdsDto (required):
Future<Response> untagAssetsWithHttpInfo(String id, AssetIdsDto assetIdsDto,) async {
/// * [BulkIdsDto] bulkIdsDto (required):
Future<Response> untagAssetsWithHttpInfo(String id, BulkIdsDto bulkIdsDto,) async {
// ignore: prefer_const_declarations
final path = r'/tags/{id}/assets'
.replaceAll('{id}', id);
// ignore: prefer_final_locals
Object? postBody = assetIdsDto;
Object? postBody = bulkIdsDto;
final queryParams = <QueryParam>[];
final headerParams = <String, String>{};
@@ -337,9 +333,9 @@ class TagsApi {
///
/// * [String] id (required):
///
/// * [AssetIdsDto] assetIdsDto (required):
Future<List<AssetIdsResponseDto>?> untagAssets(String id, AssetIdsDto assetIdsDto,) async {
final response = await untagAssetsWithHttpInfo(id, assetIdsDto,);
/// * [BulkIdsDto] bulkIdsDto (required):
Future<List<BulkIdResponseDto>?> untagAssets(String id, BulkIdsDto bulkIdsDto,) async {
final response = await untagAssetsWithHttpInfo(id, bulkIdsDto,);
if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
}
@@ -348,27 +344,27 @@ class TagsApi {
// FormatException when trying to decode an empty string.
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
final responseBody = await _decodeBodyBytes(response);
return (await apiClient.deserializeAsync(responseBody, 'List<AssetIdsResponseDto>') as List)
.cast<AssetIdsResponseDto>()
return (await apiClient.deserializeAsync(responseBody, 'List<BulkIdResponseDto>') as List)
.cast<BulkIdResponseDto>()
.toList(growable: false);
}
return null;
}
/// Performs an HTTP 'PATCH /tags/{id}' operation and returns the [Response].
/// Performs an HTTP 'PUT /tags/{id}' operation and returns the [Response].
/// Parameters:
///
/// * [String] id (required):
///
/// * [UpdateTagDto] updateTagDto (required):
Future<Response> updateTagWithHttpInfo(String id, UpdateTagDto updateTagDto,) async {
/// * [TagUpdateDto] tagUpdateDto (required):
Future<Response> updateTagWithHttpInfo(String id, TagUpdateDto tagUpdateDto,) async {
// ignore: prefer_const_declarations
final path = r'/tags/{id}'
.replaceAll('{id}', id);
// ignore: prefer_final_locals
Object? postBody = updateTagDto;
Object? postBody = tagUpdateDto;
final queryParams = <QueryParam>[];
final headerParams = <String, String>{};
@@ -379,7 +375,7 @@ class TagsApi {
return apiClient.invokeAPI(
path,
'PATCH',
'PUT',
queryParams,
postBody,
headerParams,
@@ -392,9 +388,9 @@ class TagsApi {
///
/// * [String] id (required):
///
/// * [UpdateTagDto] updateTagDto (required):
Future<TagResponseDto?> updateTag(String id, UpdateTagDto updateTagDto,) async {
final response = await updateTagWithHttpInfo(id, updateTagDto,);
/// * [TagUpdateDto] tagUpdateDto (required):
Future<TagResponseDto?> updateTag(String id, TagUpdateDto tagUpdateDto,) async {
final response = await updateTagWithHttpInfo(id, tagUpdateDto,);
if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
}
@@ -407,4 +403,54 @@ class TagsApi {
}
return null;
}
/// Performs an HTTP 'PUT /tags' operation and returns the [Response].
/// Parameters:
///
/// * [TagUpsertDto] tagUpsertDto (required):
Future<Response> upsertTagsWithHttpInfo(TagUpsertDto tagUpsertDto,) async {
// ignore: prefer_const_declarations
final path = r'/tags';
// ignore: prefer_final_locals
Object? postBody = tagUpsertDto;
final queryParams = <QueryParam>[];
final headerParams = <String, String>{};
final formParams = <String, String>{};
const contentTypes = <String>['application/json'];
return apiClient.invokeAPI(
path,
'PUT',
queryParams,
postBody,
headerParams,
formParams,
contentTypes.isEmpty ? null : contentTypes.first,
);
}
/// Parameters:
///
/// * [TagUpsertDto] tagUpsertDto (required):
Future<List<TagResponseDto>?> upsertTags(TagUpsertDto tagUpsertDto,) async {
final response = await upsertTagsWithHttpInfo(tagUpsertDto,);
if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
}
// When a remote server returns no body with a status of 204, we shall not decode it.
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
// FormatException when trying to decode an empty string.
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
final responseBody = await _decodeBodyBytes(response);
return (await apiClient.deserializeAsync(responseBody, 'List<TagResponseDto>') as List)
.cast<TagResponseDto>()
.toList(growable: false);
}
return null;
}
}

View File

@@ -37,12 +37,14 @@ class TimelineApi {
///
/// * [String] personId:
///
/// * [String] tagId:
///
/// * [String] userId:
///
/// * [bool] withPartners:
///
/// * [bool] withStacked:
Future<Response> getTimeBucketWithHttpInfo(TimeBucketSize size, String timeBucket, { String? albumId, bool? isArchived, bool? isFavorite, bool? isTrashed, String? key, AssetOrder? order, String? personId, String? userId, bool? withPartners, bool? withStacked, }) async {
Future<Response> getTimeBucketWithHttpInfo(TimeBucketSize size, String timeBucket, { String? albumId, bool? isArchived, bool? isFavorite, bool? isTrashed, String? key, AssetOrder? order, String? personId, String? tagId, String? userId, bool? withPartners, bool? withStacked, }) async {
// ignore: prefer_const_declarations
final path = r'/timeline/bucket';
@@ -75,6 +77,9 @@ class TimelineApi {
queryParams.addAll(_queryParams('', 'personId', personId));
}
queryParams.addAll(_queryParams('', 'size', size));
if (tagId != null) {
queryParams.addAll(_queryParams('', 'tagId', tagId));
}
queryParams.addAll(_queryParams('', 'timeBucket', timeBucket));
if (userId != null) {
queryParams.addAll(_queryParams('', 'userId', userId));
@@ -120,13 +125,15 @@ class TimelineApi {
///
/// * [String] personId:
///
/// * [String] tagId:
///
/// * [String] userId:
///
/// * [bool] withPartners:
///
/// * [bool] withStacked:
Future<List<AssetResponseDto>?> getTimeBucket(TimeBucketSize size, String timeBucket, { String? albumId, bool? isArchived, bool? isFavorite, bool? isTrashed, String? key, AssetOrder? order, String? personId, String? userId, bool? withPartners, bool? withStacked, }) async {
final response = await getTimeBucketWithHttpInfo(size, timeBucket, albumId: albumId, isArchived: isArchived, isFavorite: isFavorite, isTrashed: isTrashed, key: key, order: order, personId: personId, userId: userId, withPartners: withPartners, withStacked: withStacked, );
Future<List<AssetResponseDto>?> getTimeBucket(TimeBucketSize size, String timeBucket, { String? albumId, bool? isArchived, bool? isFavorite, bool? isTrashed, String? key, AssetOrder? order, String? personId, String? tagId, String? userId, bool? withPartners, bool? withStacked, }) async {
final response = await getTimeBucketWithHttpInfo(size, timeBucket, albumId: albumId, isArchived: isArchived, isFavorite: isFavorite, isTrashed: isTrashed, key: key, order: order, personId: personId, tagId: tagId, userId: userId, withPartners: withPartners, withStacked: withStacked, );
if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
}
@@ -162,12 +169,14 @@ class TimelineApi {
///
/// * [String] personId:
///
/// * [String] tagId:
///
/// * [String] userId:
///
/// * [bool] withPartners:
///
/// * [bool] withStacked:
Future<Response> getTimeBucketsWithHttpInfo(TimeBucketSize size, { String? albumId, bool? isArchived, bool? isFavorite, bool? isTrashed, String? key, AssetOrder? order, String? personId, String? userId, bool? withPartners, bool? withStacked, }) async {
Future<Response> getTimeBucketsWithHttpInfo(TimeBucketSize size, { String? albumId, bool? isArchived, bool? isFavorite, bool? isTrashed, String? key, AssetOrder? order, String? personId, String? tagId, String? userId, bool? withPartners, bool? withStacked, }) async {
// ignore: prefer_const_declarations
final path = r'/timeline/buckets';
@@ -200,6 +209,9 @@ class TimelineApi {
queryParams.addAll(_queryParams('', 'personId', personId));
}
queryParams.addAll(_queryParams('', 'size', size));
if (tagId != null) {
queryParams.addAll(_queryParams('', 'tagId', tagId));
}
if (userId != null) {
queryParams.addAll(_queryParams('', 'userId', userId));
}
@@ -242,13 +254,15 @@ class TimelineApi {
///
/// * [String] personId:
///
/// * [String] tagId:
///
/// * [String] userId:
///
/// * [bool] withPartners:
///
/// * [bool] withStacked:
Future<List<TimeBucketResponseDto>?> getTimeBuckets(TimeBucketSize size, { String? albumId, bool? isArchived, bool? isFavorite, bool? isTrashed, String? key, AssetOrder? order, String? personId, String? userId, bool? withPartners, bool? withStacked, }) async {
final response = await getTimeBucketsWithHttpInfo(size, albumId: albumId, isArchived: isArchived, isFavorite: isFavorite, isTrashed: isTrashed, key: key, order: order, personId: personId, userId: userId, withPartners: withPartners, withStacked: withStacked, );
Future<List<TimeBucketResponseDto>?> getTimeBuckets(TimeBucketSize size, { String? albumId, bool? isArchived, bool? isFavorite, bool? isTrashed, String? key, AssetOrder? order, String? personId, String? tagId, String? userId, bool? withPartners, bool? withStacked, }) async {
final response = await getTimeBucketsWithHttpInfo(size, albumId: albumId, isArchived: isArchived, isFavorite: isFavorite, isTrashed: isTrashed, key: key, order: order, personId: personId, tagId: tagId, userId: userId, withPartners: withPartners, withStacked: withStacked, );
if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
}

View File

@@ -295,8 +295,6 @@ class ApiClient {
return CreateLibraryDto.fromJson(value);
case 'CreateProfileImageResponseDto':
return CreateProfileImageResponseDto.fromJson(value);
case 'CreateTagDto':
return CreateTagDto.fromJson(value);
case 'DownloadArchiveInfo':
return DownloadArchiveInfo.fromJson(value);
case 'DownloadInfoDto':
@@ -543,10 +541,18 @@ class ApiClient {
return SystemConfigTrashDto.fromJson(value);
case 'SystemConfigUserDto':
return SystemConfigUserDto.fromJson(value);
case 'TagBulkAssetsDto':
return TagBulkAssetsDto.fromJson(value);
case 'TagBulkAssetsResponseDto':
return TagBulkAssetsResponseDto.fromJson(value);
case 'TagCreateDto':
return TagCreateDto.fromJson(value);
case 'TagResponseDto':
return TagResponseDto.fromJson(value);
case 'TagTypeEnum':
return TagTypeEnumTypeTransformer().decode(value);
case 'TagUpdateDto':
return TagUpdateDto.fromJson(value);
case 'TagUpsertDto':
return TagUpsertDto.fromJson(value);
case 'TimeBucketResponseDto':
return TimeBucketResponseDto.fromJson(value);
case 'TimeBucketSize':
@@ -567,8 +573,6 @@ class ApiClient {
return UpdateLibraryDto.fromJson(value);
case 'UpdatePartnerDto':
return UpdatePartnerDto.fromJson(value);
case 'UpdateTagDto':
return UpdateTagDto.fromJson(value);
case 'UsageByUserDto':
return UsageByUserDto.fromJson(value);
case 'UserAdminCreateDto':

View File

@@ -127,9 +127,6 @@ String parameterToString(dynamic value) {
if (value is SharedLinkType) {
return SharedLinkTypeTypeTransformer().encode(value).toString();
}
if (value is TagTypeEnum) {
return TagTypeEnumTypeTransformer().encode(value).toString();
}
if (value is TimeBucketSize) {
return TimeBucketSizeTypeTransformer().encode(value).toString();
}

View File

@@ -96,6 +96,7 @@ class Permission {
static const tagPeriodRead = Permission._(r'tag.read');
static const tagPeriodUpdate = Permission._(r'tag.update');
static const tagPeriodDelete = Permission._(r'tag.delete');
static const tagPeriodAsset = Permission._(r'tag.asset');
static const adminPeriodUserPeriodCreate = Permission._(r'admin.user.create');
static const adminPeriodUserPeriodRead = Permission._(r'admin.user.read');
static const adminPeriodUserPeriodUpdate = Permission._(r'admin.user.update');
@@ -176,6 +177,7 @@ class Permission {
tagPeriodRead,
tagPeriodUpdate,
tagPeriodDelete,
tagPeriodAsset,
adminPeriodUserPeriodCreate,
adminPeriodUserPeriodRead,
adminPeriodUserPeriodUpdate,
@@ -291,6 +293,7 @@ class PermissionTypeTransformer {
case r'tag.read': return Permission.tagPeriodRead;
case r'tag.update': return Permission.tagPeriodUpdate;
case r'tag.delete': return Permission.tagPeriodDelete;
case r'tag.asset': return Permission.tagPeriodAsset;
case r'admin.user.create': return Permission.adminPeriodUserPeriodCreate;
case r'admin.user.read': return Permission.adminPeriodUserPeriodRead;
case r'admin.user.update': return Permission.adminPeriodUserPeriodUpdate;

View File

@@ -0,0 +1,110 @@
//
// 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 TagBulkAssetsDto {
/// Returns a new [TagBulkAssetsDto] instance.
TagBulkAssetsDto({
this.assetIds = const [],
this.tagIds = const [],
});
List<String> assetIds;
List<String> tagIds;
@override
bool operator ==(Object other) => identical(this, other) || other is TagBulkAssetsDto &&
_deepEquality.equals(other.assetIds, assetIds) &&
_deepEquality.equals(other.tagIds, tagIds);
@override
int get hashCode =>
// ignore: unnecessary_parenthesis
(assetIds.hashCode) +
(tagIds.hashCode);
@override
String toString() => 'TagBulkAssetsDto[assetIds=$assetIds, tagIds=$tagIds]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
json[r'assetIds'] = this.assetIds;
json[r'tagIds'] = this.tagIds;
return json;
}
/// Returns a new [TagBulkAssetsDto] instance and imports its values from
/// [value] if it's a [Map], null otherwise.
// ignore: prefer_constructors_over_static_methods
static TagBulkAssetsDto? fromJson(dynamic value) {
if (value is Map) {
final json = value.cast<String, dynamic>();
return TagBulkAssetsDto(
assetIds: json[r'assetIds'] is Iterable
? (json[r'assetIds'] as Iterable).cast<String>().toList(growable: false)
: const [],
tagIds: json[r'tagIds'] is Iterable
? (json[r'tagIds'] as Iterable).cast<String>().toList(growable: false)
: const [],
);
}
return null;
}
static List<TagBulkAssetsDto> listFromJson(dynamic json, {bool growable = false,}) {
final result = <TagBulkAssetsDto>[];
if (json is List && json.isNotEmpty) {
for (final row in json) {
final value = TagBulkAssetsDto.fromJson(row);
if (value != null) {
result.add(value);
}
}
}
return result.toList(growable: growable);
}
static Map<String, TagBulkAssetsDto> mapFromJson(dynamic json) {
final map = <String, TagBulkAssetsDto>{};
if (json is Map && json.isNotEmpty) {
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
for (final entry in json.entries) {
final value = TagBulkAssetsDto.fromJson(entry.value);
if (value != null) {
map[entry.key] = value;
}
}
}
return map;
}
// maps a json object with a list of TagBulkAssetsDto-objects as value to a dart map
static Map<String, List<TagBulkAssetsDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
final map = <String, List<TagBulkAssetsDto>>{};
if (json is Map && json.isNotEmpty) {
// ignore: parameter_assignments
json = json.cast<String, dynamic>();
for (final entry in json.entries) {
map[entry.key] = TagBulkAssetsDto.listFromJson(entry.value, growable: growable,);
}
}
return map;
}
/// The list of required keys that must be present in a JSON.
static const requiredKeys = <String>{
'assetIds',
'tagIds',
};
}

View File

@@ -0,0 +1,98 @@
//
// 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 TagBulkAssetsResponseDto {
/// Returns a new [TagBulkAssetsResponseDto] instance.
TagBulkAssetsResponseDto({
required this.count,
});
int count;
@override
bool operator ==(Object other) => identical(this, other) || other is TagBulkAssetsResponseDto &&
other.count == count;
@override
int get hashCode =>
// ignore: unnecessary_parenthesis
(count.hashCode);
@override
String toString() => 'TagBulkAssetsResponseDto[count=$count]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
json[r'count'] = this.count;
return json;
}
/// Returns a new [TagBulkAssetsResponseDto] instance and imports its values from
/// [value] if it's a [Map], null otherwise.
// ignore: prefer_constructors_over_static_methods
static TagBulkAssetsResponseDto? fromJson(dynamic value) {
if (value is Map) {
final json = value.cast<String, dynamic>();
return TagBulkAssetsResponseDto(
count: mapValueOfType<int>(json, r'count')!,
);
}
return null;
}
static List<TagBulkAssetsResponseDto> listFromJson(dynamic json, {bool growable = false,}) {
final result = <TagBulkAssetsResponseDto>[];
if (json is List && json.isNotEmpty) {
for (final row in json) {
final value = TagBulkAssetsResponseDto.fromJson(row);
if (value != null) {
result.add(value);
}
}
}
return result.toList(growable: growable);
}
static Map<String, TagBulkAssetsResponseDto> mapFromJson(dynamic json) {
final map = <String, TagBulkAssetsResponseDto>{};
if (json is Map && json.isNotEmpty) {
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
for (final entry in json.entries) {
final value = TagBulkAssetsResponseDto.fromJson(entry.value);
if (value != null) {
map[entry.key] = value;
}
}
}
return map;
}
// maps a json object with a list of TagBulkAssetsResponseDto-objects as value to a dart map
static Map<String, List<TagBulkAssetsResponseDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
final map = <String, List<TagBulkAssetsResponseDto>>{};
if (json is Map && json.isNotEmpty) {
// ignore: parameter_assignments
json = json.cast<String, dynamic>();
for (final entry in json.entries) {
map[entry.key] = TagBulkAssetsResponseDto.listFromJson(entry.value, growable: growable,);
}
}
return map;
}
/// The list of required keys that must be present in a JSON.
static const requiredKeys = <String>{
'count',
};
}

View File

@@ -10,10 +10,12 @@
part of openapi.api;
class UpdateTagDto {
/// Returns a new [UpdateTagDto] instance.
UpdateTagDto({
this.name,
class TagCreateDto {
/// Returns a new [TagCreateDto] instance.
TagCreateDto({
this.color,
required this.name,
this.parentId,
});
///
@@ -22,49 +24,65 @@ class UpdateTagDto {
/// source code must fall back to having a nullable type.
/// Consider adding a "default:" property in the specification file to hide this note.
///
String? name;
String? color;
String name;
String? parentId;
@override
bool operator ==(Object other) => identical(this, other) || other is UpdateTagDto &&
other.name == name;
bool operator ==(Object other) => identical(this, other) || other is TagCreateDto &&
other.color == color &&
other.name == name &&
other.parentId == parentId;
@override
int get hashCode =>
// ignore: unnecessary_parenthesis
(name == null ? 0 : name!.hashCode);
(color == null ? 0 : color!.hashCode) +
(name.hashCode) +
(parentId == null ? 0 : parentId!.hashCode);
@override
String toString() => 'UpdateTagDto[name=$name]';
String toString() => 'TagCreateDto[color=$color, name=$name, parentId=$parentId]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
if (this.name != null) {
json[r'name'] = this.name;
if (this.color != null) {
json[r'color'] = this.color;
} else {
// json[r'name'] = null;
// json[r'color'] = null;
}
json[r'name'] = this.name;
if (this.parentId != null) {
json[r'parentId'] = this.parentId;
} else {
// json[r'parentId'] = null;
}
return json;
}
/// Returns a new [UpdateTagDto] instance and imports its values from
/// Returns a new [TagCreateDto] instance and imports its values from
/// [value] if it's a [Map], null otherwise.
// ignore: prefer_constructors_over_static_methods
static UpdateTagDto? fromJson(dynamic value) {
static TagCreateDto? fromJson(dynamic value) {
if (value is Map) {
final json = value.cast<String, dynamic>();
return UpdateTagDto(
name: mapValueOfType<String>(json, r'name'),
return TagCreateDto(
color: mapValueOfType<String>(json, r'color'),
name: mapValueOfType<String>(json, r'name')!,
parentId: mapValueOfType<String>(json, r'parentId'),
);
}
return null;
}
static List<UpdateTagDto> listFromJson(dynamic json, {bool growable = false,}) {
final result = <UpdateTagDto>[];
static List<TagCreateDto> listFromJson(dynamic json, {bool growable = false,}) {
final result = <TagCreateDto>[];
if (json is List && json.isNotEmpty) {
for (final row in json) {
final value = UpdateTagDto.fromJson(row);
final value = TagCreateDto.fromJson(row);
if (value != null) {
result.add(value);
}
@@ -73,12 +91,12 @@ class UpdateTagDto {
return result.toList(growable: growable);
}
static Map<String, UpdateTagDto> mapFromJson(dynamic json) {
final map = <String, UpdateTagDto>{};
static Map<String, TagCreateDto> mapFromJson(dynamic json) {
final map = <String, TagCreateDto>{};
if (json is Map && json.isNotEmpty) {
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
for (final entry in json.entries) {
final value = UpdateTagDto.fromJson(entry.value);
final value = TagCreateDto.fromJson(entry.value);
if (value != null) {
map[entry.key] = value;
}
@@ -87,14 +105,14 @@ class UpdateTagDto {
return map;
}
// maps a json object with a list of UpdateTagDto-objects as value to a dart map
static Map<String, List<UpdateTagDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
final map = <String, List<UpdateTagDto>>{};
// maps a json object with a list of TagCreateDto-objects as value to a dart map
static Map<String, List<TagCreateDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
final map = <String, List<TagCreateDto>>{};
if (json is Map && json.isNotEmpty) {
// ignore: parameter_assignments
json = json.cast<String, dynamic>();
for (final entry in json.entries) {
map[entry.key] = UpdateTagDto.listFromJson(entry.value, growable: growable,);
map[entry.key] = TagCreateDto.listFromJson(entry.value, growable: growable,);
}
}
return map;
@@ -102,6 +120,7 @@ class UpdateTagDto {
/// The list of required keys that must be present in a JSON.
static const requiredKeys = <String>{
'name',
};
}

View File

@@ -13,44 +13,66 @@ part of openapi.api;
class TagResponseDto {
/// Returns a new [TagResponseDto] instance.
TagResponseDto({
this.color,
required this.createdAt,
required this.id,
required this.name,
required this.type,
required this.userId,
required this.updatedAt,
required this.value,
});
///
/// Please note: This property should have been non-nullable! Since the specification file
/// does not include a default value (using the "default:" property), however, the generated
/// source code must fall back to having a nullable type.
/// Consider adding a "default:" property in the specification file to hide this note.
///
String? color;
DateTime createdAt;
String id;
String name;
TagTypeEnum type;
DateTime updatedAt;
String userId;
String value;
@override
bool operator ==(Object other) => identical(this, other) || other is TagResponseDto &&
other.color == color &&
other.createdAt == createdAt &&
other.id == id &&
other.name == name &&
other.type == type &&
other.userId == userId;
other.updatedAt == updatedAt &&
other.value == value;
@override
int get hashCode =>
// ignore: unnecessary_parenthesis
(color == null ? 0 : color!.hashCode) +
(createdAt.hashCode) +
(id.hashCode) +
(name.hashCode) +
(type.hashCode) +
(userId.hashCode);
(updatedAt.hashCode) +
(value.hashCode);
@override
String toString() => 'TagResponseDto[id=$id, name=$name, type=$type, userId=$userId]';
String toString() => 'TagResponseDto[color=$color, createdAt=$createdAt, id=$id, name=$name, updatedAt=$updatedAt, value=$value]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
if (this.color != null) {
json[r'color'] = this.color;
} else {
// json[r'color'] = null;
}
json[r'createdAt'] = this.createdAt.toUtc().toIso8601String();
json[r'id'] = this.id;
json[r'name'] = this.name;
json[r'type'] = this.type;
json[r'userId'] = this.userId;
json[r'updatedAt'] = this.updatedAt.toUtc().toIso8601String();
json[r'value'] = this.value;
return json;
}
@@ -62,10 +84,12 @@ class TagResponseDto {
final json = value.cast<String, dynamic>();
return TagResponseDto(
color: mapValueOfType<String>(json, r'color'),
createdAt: mapDateTime(json, r'createdAt', r'')!,
id: mapValueOfType<String>(json, r'id')!,
name: mapValueOfType<String>(json, r'name')!,
type: TagTypeEnum.fromJson(json[r'type'])!,
userId: mapValueOfType<String>(json, r'userId')!,
updatedAt: mapDateTime(json, r'updatedAt', r'')!,
value: mapValueOfType<String>(json, r'value')!,
);
}
return null;
@@ -113,10 +137,11 @@ class TagResponseDto {
/// The list of required keys that must be present in a JSON.
static const requiredKeys = <String>{
'createdAt',
'id',
'name',
'type',
'userId',
'updatedAt',
'value',
};
}

View File

@@ -1,88 +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 TagTypeEnum {
/// Instantiate a new enum with the provided [value].
const TagTypeEnum._(this.value);
/// The underlying value of this enum member.
final String value;
@override
String toString() => value;
String toJson() => value;
static const OBJECT = TagTypeEnum._(r'OBJECT');
static const FACE = TagTypeEnum._(r'FACE');
static const CUSTOM = TagTypeEnum._(r'CUSTOM');
/// List of all possible values in this [enum][TagTypeEnum].
static const values = <TagTypeEnum>[
OBJECT,
FACE,
CUSTOM,
];
static TagTypeEnum? fromJson(dynamic value) => TagTypeEnumTypeTransformer().decode(value);
static List<TagTypeEnum> listFromJson(dynamic json, {bool growable = false,}) {
final result = <TagTypeEnum>[];
if (json is List && json.isNotEmpty) {
for (final row in json) {
final value = TagTypeEnum.fromJson(row);
if (value != null) {
result.add(value);
}
}
}
return result.toList(growable: growable);
}
}
/// Transformation class that can [encode] an instance of [TagTypeEnum] to String,
/// and [decode] dynamic data back to [TagTypeEnum].
class TagTypeEnumTypeTransformer {
factory TagTypeEnumTypeTransformer() => _instance ??= const TagTypeEnumTypeTransformer._();
const TagTypeEnumTypeTransformer._();
String encode(TagTypeEnum data) => data.value;
/// Decodes a [dynamic value][data] to a TagTypeEnum.
///
/// 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.
TagTypeEnum? decode(dynamic data, {bool allowNull = true}) {
if (data != null) {
switch (data) {
case r'OBJECT': return TagTypeEnum.OBJECT;
case r'FACE': return TagTypeEnum.FACE;
case r'CUSTOM': return TagTypeEnum.CUSTOM;
default:
if (!allowNull) {
throw ArgumentError('Unknown enum value to decode: $data');
}
}
}
return null;
}
/// Singleton [TagTypeEnumTypeTransformer] instance.
static TagTypeEnumTypeTransformer? _instance;
}

View File

@@ -10,58 +10,55 @@
part of openapi.api;
class CreateTagDto {
/// Returns a new [CreateTagDto] instance.
CreateTagDto({
required this.name,
required this.type,
class TagUpdateDto {
/// Returns a new [TagUpdateDto] instance.
TagUpdateDto({
this.color,
});
String name;
TagTypeEnum type;
String? color;
@override
bool operator ==(Object other) => identical(this, other) || other is CreateTagDto &&
other.name == name &&
other.type == type;
bool operator ==(Object other) => identical(this, other) || other is TagUpdateDto &&
other.color == color;
@override
int get hashCode =>
// ignore: unnecessary_parenthesis
(name.hashCode) +
(type.hashCode);
(color == null ? 0 : color!.hashCode);
@override
String toString() => 'CreateTagDto[name=$name, type=$type]';
String toString() => 'TagUpdateDto[color=$color]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
json[r'name'] = this.name;
json[r'type'] = this.type;
if (this.color != null) {
json[r'color'] = this.color;
} else {
// json[r'color'] = null;
}
return json;
}
/// Returns a new [CreateTagDto] instance and imports its values from
/// Returns a new [TagUpdateDto] instance and imports its values from
/// [value] if it's a [Map], null otherwise.
// ignore: prefer_constructors_over_static_methods
static CreateTagDto? fromJson(dynamic value) {
static TagUpdateDto? fromJson(dynamic value) {
if (value is Map) {
final json = value.cast<String, dynamic>();
return CreateTagDto(
name: mapValueOfType<String>(json, r'name')!,
type: TagTypeEnum.fromJson(json[r'type'])!,
return TagUpdateDto(
color: mapValueOfType<String>(json, r'color'),
);
}
return null;
}
static List<CreateTagDto> listFromJson(dynamic json, {bool growable = false,}) {
final result = <CreateTagDto>[];
static List<TagUpdateDto> listFromJson(dynamic json, {bool growable = false,}) {
final result = <TagUpdateDto>[];
if (json is List && json.isNotEmpty) {
for (final row in json) {
final value = CreateTagDto.fromJson(row);
final value = TagUpdateDto.fromJson(row);
if (value != null) {
result.add(value);
}
@@ -70,12 +67,12 @@ class CreateTagDto {
return result.toList(growable: growable);
}
static Map<String, CreateTagDto> mapFromJson(dynamic json) {
final map = <String, CreateTagDto>{};
static Map<String, TagUpdateDto> mapFromJson(dynamic json) {
final map = <String, TagUpdateDto>{};
if (json is Map && json.isNotEmpty) {
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
for (final entry in json.entries) {
final value = CreateTagDto.fromJson(entry.value);
final value = TagUpdateDto.fromJson(entry.value);
if (value != null) {
map[entry.key] = value;
}
@@ -84,14 +81,14 @@ class CreateTagDto {
return map;
}
// maps a json object with a list of CreateTagDto-objects as value to a dart map
static Map<String, List<CreateTagDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
final map = <String, List<CreateTagDto>>{};
// maps a json object with a list of TagUpdateDto-objects as value to a dart map
static Map<String, List<TagUpdateDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
final map = <String, List<TagUpdateDto>>{};
if (json is Map && json.isNotEmpty) {
// ignore: parameter_assignments
json = json.cast<String, dynamic>();
for (final entry in json.entries) {
map[entry.key] = CreateTagDto.listFromJson(entry.value, growable: growable,);
map[entry.key] = TagUpdateDto.listFromJson(entry.value, growable: growable,);
}
}
return map;
@@ -99,8 +96,6 @@ class CreateTagDto {
/// The list of required keys that must be present in a JSON.
static const requiredKeys = <String>{
'name',
'type',
};
}

View File

@@ -0,0 +1,100 @@
//
// 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 TagUpsertDto {
/// Returns a new [TagUpsertDto] instance.
TagUpsertDto({
this.tags = const [],
});
List<String> tags;
@override
bool operator ==(Object other) => identical(this, other) || other is TagUpsertDto &&
_deepEquality.equals(other.tags, tags);
@override
int get hashCode =>
// ignore: unnecessary_parenthesis
(tags.hashCode);
@override
String toString() => 'TagUpsertDto[tags=$tags]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
json[r'tags'] = this.tags;
return json;
}
/// Returns a new [TagUpsertDto] instance and imports its values from
/// [value] if it's a [Map], null otherwise.
// ignore: prefer_constructors_over_static_methods
static TagUpsertDto? fromJson(dynamic value) {
if (value is Map) {
final json = value.cast<String, dynamic>();
return TagUpsertDto(
tags: json[r'tags'] is Iterable
? (json[r'tags'] as Iterable).cast<String>().toList(growable: false)
: const [],
);
}
return null;
}
static List<TagUpsertDto> listFromJson(dynamic json, {bool growable = false,}) {
final result = <TagUpsertDto>[];
if (json is List && json.isNotEmpty) {
for (final row in json) {
final value = TagUpsertDto.fromJson(row);
if (value != null) {
result.add(value);
}
}
}
return result.toList(growable: growable);
}
static Map<String, TagUpsertDto> mapFromJson(dynamic json) {
final map = <String, TagUpsertDto>{};
if (json is Map && json.isNotEmpty) {
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
for (final entry in json.entries) {
final value = TagUpsertDto.fromJson(entry.value);
if (value != null) {
map[entry.key] = value;
}
}
}
return map;
}
// maps a json object with a list of TagUpsertDto-objects as value to a dart map
static Map<String, List<TagUpsertDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
final map = <String, List<TagUpsertDto>>{};
if (json is Map && json.isNotEmpty) {
// ignore: parameter_assignments
json = json.cast<String, dynamic>();
for (final entry in json.entries) {
map[entry.key] = TagUpsertDto.listFromJson(entry.value, growable: growable,);
}
}
return map;
}
/// The list of required keys that must be present in a JSON.
static const requiredKeys = <String>{
'tags',
};
}