From c035a60558d1b3f17e7358d0e6ef984a80295253 Mon Sep 17 00:00:00 2001 From: rikifrank Date: Thu, 9 Nov 2023 12:20:15 +0200 Subject: [PATCH] expandedPersonResponseDto --- cli/src/api/open-api/api.ts | 77 ++++++- mobile/openapi/.openapi-generator/FILES | 3 + mobile/openapi/README.md | 1 + mobile/openapi/doc/AssetResponseDto.md | 2 +- .../openapi/doc/ExpandedPersonResponseDto.md | 25 +++ mobile/openapi/lib/api.dart | 1 + mobile/openapi/lib/api_client.dart | 2 + .../openapi/lib/model/asset_response_dto.dart | 4 +- .../model/expanded_person_response_dto.dart | 194 ++++++++++++++++++ .../openapi/test/asset_response_dto_test.dart | 2 +- .../expanded_person_response_dto_test.dart | 77 +++++++ server/immich-openapi-specs.json | 55 ++++- .../asset/response-dto/asset-response.dto.ts | 2 +- web/src/api/open-api/api.ts | 77 ++++++- 14 files changed, 512 insertions(+), 10 deletions(-) create mode 100644 mobile/openapi/doc/ExpandedPersonResponseDto.md create mode 100644 mobile/openapi/lib/model/expanded_person_response_dto.dart create mode 100644 mobile/openapi/test/expanded_person_response_dto_test.dart diff --git a/cli/src/api/open-api/api.ts b/cli/src/api/open-api/api.ts index 9bd80c020f154..0a82aba88fe89 100644 --- a/cli/src/api/open-api/api.ts +++ b/cli/src/api/open-api/api.ts @@ -878,10 +878,10 @@ export interface AssetResponseDto { 'ownerId': string; /** * - * @type {Array} + * @type {Array} * @memberof AssetResponseDto */ - 'people'?: Array; + 'people'?: Array; /** * * @type {boolean} @@ -1730,6 +1730,79 @@ export interface ExifResponseDto { */ 'timeZone'?: string | null; } +/** + * + * @export + * @interface ExpandedPersonResponseDto + */ +export interface ExpandedPersonResponseDto { + /** + * + * @type {string} + * @memberof ExpandedPersonResponseDto + */ + 'birthDate': string | null; + /** + * + * @type {string} + * @memberof ExpandedPersonResponseDto + */ + 'id': string; + /** + * + * @type {number} + * @memberof ExpandedPersonResponseDto + */ + 'imageHeight': number; + /** + * + * @type {number} + * @memberof ExpandedPersonResponseDto + */ + 'imageWidth': number; + /** + * + * @type {boolean} + * @memberof ExpandedPersonResponseDto + */ + 'isHidden': boolean; + /** + * + * @type {string} + * @memberof ExpandedPersonResponseDto + */ + 'name': string; + /** + * + * @type {string} + * @memberof ExpandedPersonResponseDto + */ + 'thumbnailPath': string; + /** + * + * @type {number} + * @memberof ExpandedPersonResponseDto + */ + 'x1': number; + /** + * + * @type {number} + * @memberof ExpandedPersonResponseDto + */ + 'x2': number; + /** + * + * @type {number} + * @memberof ExpandedPersonResponseDto + */ + 'y1': number; + /** + * + * @type {number} + * @memberof ExpandedPersonResponseDto + */ + 'y2': number; +} /** * * @export diff --git a/mobile/openapi/.openapi-generator/FILES b/mobile/openapi/.openapi-generator/FILES index 6e437ff16cc96..58fb5f84ac4dc 100644 --- a/mobile/openapi/.openapi-generator/FILES +++ b/mobile/openapi/.openapi-generator/FILES @@ -62,6 +62,7 @@ doc/DownloadInfoDto.md doc/DownloadResponseDto.md doc/EntityType.md doc/ExifResponseDto.md +doc/ExpandedPersonResponseDto.md doc/FileChecksumDto.md doc/FileChecksumResponseDto.md doc/FileReportDto.md @@ -249,6 +250,7 @@ lib/model/download_info_dto.dart lib/model/download_response_dto.dart lib/model/entity_type.dart lib/model/exif_response_dto.dart +lib/model/expanded_person_response_dto.dart lib/model/file_checksum_dto.dart lib/model/file_checksum_response_dto.dart lib/model/file_report_dto.dart @@ -405,6 +407,7 @@ test/download_info_dto_test.dart test/download_response_dto_test.dart test/entity_type_test.dart test/exif_response_dto_test.dart +test/expanded_person_response_dto_test.dart test/file_checksum_dto_test.dart test/file_checksum_response_dto_test.dart test/file_report_dto_test.dart diff --git a/mobile/openapi/README.md b/mobile/openapi/README.md index 931cb4fae7abc..d2e0cf2d1d7cc 100644 --- a/mobile/openapi/README.md +++ b/mobile/openapi/README.md @@ -259,6 +259,7 @@ Class | Method | HTTP request | Description - [DownloadResponseDto](doc//DownloadResponseDto.md) - [EntityType](doc//EntityType.md) - [ExifResponseDto](doc//ExifResponseDto.md) + - [ExpandedPersonResponseDto](doc//ExpandedPersonResponseDto.md) - [FileChecksumDto](doc//FileChecksumDto.md) - [FileChecksumResponseDto](doc//FileChecksumResponseDto.md) - [FileReportDto](doc//FileReportDto.md) diff --git a/mobile/openapi/doc/AssetResponseDto.md b/mobile/openapi/doc/AssetResponseDto.md index 8c4d1db4a74fe..cb4fc1a35c04f 100644 --- a/mobile/openapi/doc/AssetResponseDto.md +++ b/mobile/openapi/doc/AssetResponseDto.md @@ -30,7 +30,7 @@ Name | Type | Description | Notes **originalPath** | **String** | | **owner** | [**UserResponseDto**](UserResponseDto.md) | | [optional] **ownerId** | **String** | | -**people** | [**List**](PersonResponseDto.md) | | [optional] [default to const []] +**people** | [**List**](ExpandedPersonResponseDto.md) | | [optional] [default to const []] **resized** | **bool** | | **smartInfo** | [**SmartInfoResponseDto**](SmartInfoResponseDto.md) | | [optional] **stack** | [**List**](AssetResponseDto.md) | | [optional] [default to const []] diff --git a/mobile/openapi/doc/ExpandedPersonResponseDto.md b/mobile/openapi/doc/ExpandedPersonResponseDto.md new file mode 100644 index 0000000000000..eddc8a6c1bbdf --- /dev/null +++ b/mobile/openapi/doc/ExpandedPersonResponseDto.md @@ -0,0 +1,25 @@ +# openapi.model.ExpandedPersonResponseDto + +## Load the model package +```dart +import 'package:openapi/api.dart'; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**birthDate** | [**DateTime**](DateTime.md) | | +**id** | **String** | | +**imageHeight** | **num** | | +**imageWidth** | **num** | | +**isHidden** | **bool** | | +**name** | **String** | | +**thumbnailPath** | **String** | | +**x1** | **num** | | +**x2** | **num** | | +**y1** | **num** | | +**y2** | **num** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/mobile/openapi/lib/api.dart b/mobile/openapi/lib/api.dart index a537bcb335a7b..e1fb0bc4fbfc9 100644 --- a/mobile/openapi/lib/api.dart +++ b/mobile/openapi/lib/api.dart @@ -99,6 +99,7 @@ part 'model/download_info_dto.dart'; part 'model/download_response_dto.dart'; part 'model/entity_type.dart'; part 'model/exif_response_dto.dart'; +part 'model/expanded_person_response_dto.dart'; part 'model/file_checksum_dto.dart'; part 'model/file_checksum_response_dto.dart'; part 'model/file_report_dto.dart'; diff --git a/mobile/openapi/lib/api_client.dart b/mobile/openapi/lib/api_client.dart index 1ff7906fa5939..bae6b7fa32e1d 100644 --- a/mobile/openapi/lib/api_client.dart +++ b/mobile/openapi/lib/api_client.dart @@ -287,6 +287,8 @@ class ApiClient { return EntityTypeTypeTransformer().decode(value); case 'ExifResponseDto': return ExifResponseDto.fromJson(value); + case 'ExpandedPersonResponseDto': + return ExpandedPersonResponseDto.fromJson(value); case 'FileChecksumDto': return FileChecksumDto.fromJson(value); case 'FileChecksumResponseDto': diff --git a/mobile/openapi/lib/model/asset_response_dto.dart b/mobile/openapi/lib/model/asset_response_dto.dart index 7461186810246..635e424dc99d6 100644 --- a/mobile/openapi/lib/model/asset_response_dto.dart +++ b/mobile/openapi/lib/model/asset_response_dto.dart @@ -104,7 +104,7 @@ class AssetResponseDto { String ownerId; - List people; + List people; bool resized; @@ -299,7 +299,7 @@ class AssetResponseDto { originalPath: mapValueOfType(json, r'originalPath')!, owner: UserResponseDto.fromJson(json[r'owner']), ownerId: mapValueOfType(json, r'ownerId')!, - people: PersonResponseDto.listFromJson(json[r'people']), + people: ExpandedPersonResponseDto.listFromJson(json[r'people']), resized: mapValueOfType(json, r'resized')!, smartInfo: SmartInfoResponseDto.fromJson(json[r'smartInfo']), stack: AssetResponseDto.listFromJson(json[r'stack']), diff --git a/mobile/openapi/lib/model/expanded_person_response_dto.dart b/mobile/openapi/lib/model/expanded_person_response_dto.dart new file mode 100644 index 0000000000000..9c2a61f8795b2 --- /dev/null +++ b/mobile/openapi/lib/model/expanded_person_response_dto.dart @@ -0,0 +1,194 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// +// @dart=2.12 + +// 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 ExpandedPersonResponseDto { + /// Returns a new [ExpandedPersonResponseDto] instance. + ExpandedPersonResponseDto({ + required this.birthDate, + required this.id, + required this.imageHeight, + required this.imageWidth, + required this.isHidden, + required this.name, + required this.thumbnailPath, + required this.x1, + required this.x2, + required this.y1, + required this.y2, + }); + + DateTime? birthDate; + + String id; + + num imageHeight; + + num imageWidth; + + bool isHidden; + + String name; + + String thumbnailPath; + + num x1; + + num x2; + + num y1; + + num y2; + + @override + bool operator ==(Object other) => identical(this, other) || other is ExpandedPersonResponseDto && + other.birthDate == birthDate && + other.id == id && + other.imageHeight == imageHeight && + other.imageWidth == imageWidth && + other.isHidden == isHidden && + other.name == name && + other.thumbnailPath == thumbnailPath && + other.x1 == x1 && + other.x2 == x2 && + other.y1 == y1 && + other.y2 == y2; + + @override + int get hashCode => + // ignore: unnecessary_parenthesis + (birthDate == null ? 0 : birthDate!.hashCode) + + (id.hashCode) + + (imageHeight.hashCode) + + (imageWidth.hashCode) + + (isHidden.hashCode) + + (name.hashCode) + + (thumbnailPath.hashCode) + + (x1.hashCode) + + (x2.hashCode) + + (y1.hashCode) + + (y2.hashCode); + + @override + String toString() => 'ExpandedPersonResponseDto[birthDate=$birthDate, id=$id, imageHeight=$imageHeight, imageWidth=$imageWidth, isHidden=$isHidden, name=$name, thumbnailPath=$thumbnailPath, x1=$x1, x2=$x2, y1=$y1, y2=$y2]'; + + Map toJson() { + final json = {}; + if (this.birthDate != null) { + json[r'birthDate'] = _dateFormatter.format(this.birthDate!.toUtc()); + } else { + // json[r'birthDate'] = null; + } + json[r'id'] = this.id; + json[r'imageHeight'] = this.imageHeight; + json[r'imageWidth'] = this.imageWidth; + json[r'isHidden'] = this.isHidden; + json[r'name'] = this.name; + json[r'thumbnailPath'] = this.thumbnailPath; + json[r'x1'] = this.x1; + json[r'x2'] = this.x2; + json[r'y1'] = this.y1; + json[r'y2'] = this.y2; + return json; + } + + /// Returns a new [ExpandedPersonResponseDto] instance and imports its values from + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static ExpandedPersonResponseDto? fromJson(dynamic value) { + if (value is Map) { + final json = value.cast(); + + return ExpandedPersonResponseDto( + birthDate: mapDateTime(json, r'birthDate', ''), + id: mapValueOfType(json, r'id')!, + imageHeight: json[r'imageHeight'] == null + ? null + : num.parse(json[r'imageHeight'].toString()), + imageWidth: json[r'imageWidth'] == null + ? null + : num.parse(json[r'imageWidth'].toString()), + isHidden: mapValueOfType(json, r'isHidden')!, + name: mapValueOfType(json, r'name')!, + thumbnailPath: mapValueOfType(json, r'thumbnailPath')!, + x1: json[r'x1'] == null + ? null + : num.parse(json[r'x1'].toString()), + x2: json[r'x2'] == null + ? null + : num.parse(json[r'x2'].toString()), + y1: json[r'y1'] == null + ? null + : num.parse(json[r'y1'].toString()), + y2: json[r'y2'] == null + ? null + : num.parse(json[r'y2'].toString()), + ); + } + return null; + } + + static List listFromJson(dynamic json, {bool growable = false,}) { + final result = []; + if (json is List && json.isNotEmpty) { + for (final row in json) { + final value = ExpandedPersonResponseDto.fromJson(row); + if (value != null) { + result.add(value); + } + } + } + return result.toList(growable: growable); + } + + static Map mapFromJson(dynamic json) { + final map = {}; + if (json is Map && json.isNotEmpty) { + json = json.cast(); // ignore: parameter_assignments + for (final entry in json.entries) { + final value = ExpandedPersonResponseDto.fromJson(entry.value); + if (value != null) { + map[entry.key] = value; + } + } + } + return map; + } + + // maps a json object with a list of ExpandedPersonResponseDto-objects as value to a dart map + static Map> mapListFromJson(dynamic json, {bool growable = false,}) { + final map = >{}; + if (json is Map && json.isNotEmpty) { + // ignore: parameter_assignments + json = json.cast(); + for (final entry in json.entries) { + map[entry.key] = ExpandedPersonResponseDto.listFromJson(entry.value, growable: growable,); + } + } + return map; + } + + /// The list of required keys that must be present in a JSON. + static const requiredKeys = { + 'birthDate', + 'id', + 'imageHeight', + 'imageWidth', + 'isHidden', + 'name', + 'thumbnailPath', + 'x1', + 'x2', + 'y1', + 'y2', + }; +} + diff --git a/mobile/openapi/test/asset_response_dto_test.dart b/mobile/openapi/test/asset_response_dto_test.dart index 63668934a9574..b0aad7710110e 100644 --- a/mobile/openapi/test/asset_response_dto_test.dart +++ b/mobile/openapi/test/asset_response_dto_test.dart @@ -127,7 +127,7 @@ void main() { // TODO }); - // List people (default value: const []) + // List people (default value: const []) test('to test the property `people`', () async { // TODO }); diff --git a/mobile/openapi/test/expanded_person_response_dto_test.dart b/mobile/openapi/test/expanded_person_response_dto_test.dart new file mode 100644 index 0000000000000..e0c52c1181f1c --- /dev/null +++ b/mobile/openapi/test/expanded_person_response_dto_test.dart @@ -0,0 +1,77 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// +// @dart=2.12 + +// 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 + +import 'package:openapi/api.dart'; +import 'package:test/test.dart'; + +// tests for ExpandedPersonResponseDto +void main() { + // final instance = ExpandedPersonResponseDto(); + + group('test ExpandedPersonResponseDto', () { + // DateTime birthDate + test('to test the property `birthDate`', () async { + // TODO + }); + + // String id + test('to test the property `id`', () async { + // TODO + }); + + // num imageHeight + test('to test the property `imageHeight`', () async { + // TODO + }); + + // num imageWidth + test('to test the property `imageWidth`', () async { + // TODO + }); + + // bool isHidden + test('to test the property `isHidden`', () async { + // TODO + }); + + // String name + test('to test the property `name`', () async { + // TODO + }); + + // String thumbnailPath + test('to test the property `thumbnailPath`', () async { + // TODO + }); + + // num x1 + test('to test the property `x1`', () async { + // TODO + }); + + // num x2 + test('to test the property `x2`', () async { + // TODO + }); + + // num y1 + test('to test the property `y1`', () async { + // TODO + }); + + // num y2 + test('to test the property `y2`', () async { + // TODO + }); + + + }); + +} diff --git a/server/immich-openapi-specs.json b/server/immich-openapi-specs.json index 0200edbf9b985..121bc50e10233 100644 --- a/server/immich-openapi-specs.json +++ b/server/immich-openapi-specs.json @@ -6387,7 +6387,7 @@ }, "people": { "items": { - "$ref": "#/components/schemas/PersonResponseDto" + "$ref": "#/components/schemas/ExpandedPersonResponseDto" }, "type": "array" }, @@ -7133,6 +7133,59 @@ }, "type": "object" }, + "ExpandedPersonResponseDto": { + "properties": { + "birthDate": { + "format": "date", + "nullable": true, + "type": "string" + }, + "id": { + "type": "string" + }, + "imageHeight": { + "type": "number" + }, + "imageWidth": { + "type": "number" + }, + "isHidden": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "thumbnailPath": { + "type": "string" + }, + "x1": { + "type": "number" + }, + "x2": { + "type": "number" + }, + "y1": { + "type": "number" + }, + "y2": { + "type": "number" + } + }, + "required": [ + "birthDate", + "x1", + "x2", + "y1", + "y2", + "imageWidth", + "imageHeight", + "id", + "name", + "thumbnailPath", + "isHidden" + ], + "type": "object" + }, "FileChecksumDto": { "properties": { "filenames": { diff --git a/server/src/domain/asset/response-dto/asset-response.dto.ts b/server/src/domain/asset/response-dto/asset-response.dto.ts index 768126e6a846b..408766f29c52d 100644 --- a/server/src/domain/asset/response-dto/asset-response.dto.ts +++ b/server/src/domain/asset/response-dto/asset-response.dto.ts @@ -39,7 +39,7 @@ export class AssetResponseDto extends SanitizedAssetResponseDto { exifInfo?: ExifResponseDto; smartInfo?: SmartInfoResponseDto; tags?: TagResponseDto[]; - people?: PersonResponseDto[]; + people?: ExpandedPersonResponseDto[]; /**base64 encoded sha1 hash */ checksum!: string; stackParentId?: string | null; diff --git a/web/src/api/open-api/api.ts b/web/src/api/open-api/api.ts index 9bd80c020f154..0a82aba88fe89 100644 --- a/web/src/api/open-api/api.ts +++ b/web/src/api/open-api/api.ts @@ -878,10 +878,10 @@ export interface AssetResponseDto { 'ownerId': string; /** * - * @type {Array} + * @type {Array} * @memberof AssetResponseDto */ - 'people'?: Array; + 'people'?: Array; /** * * @type {boolean} @@ -1730,6 +1730,79 @@ export interface ExifResponseDto { */ 'timeZone'?: string | null; } +/** + * + * @export + * @interface ExpandedPersonResponseDto + */ +export interface ExpandedPersonResponseDto { + /** + * + * @type {string} + * @memberof ExpandedPersonResponseDto + */ + 'birthDate': string | null; + /** + * + * @type {string} + * @memberof ExpandedPersonResponseDto + */ + 'id': string; + /** + * + * @type {number} + * @memberof ExpandedPersonResponseDto + */ + 'imageHeight': number; + /** + * + * @type {number} + * @memberof ExpandedPersonResponseDto + */ + 'imageWidth': number; + /** + * + * @type {boolean} + * @memberof ExpandedPersonResponseDto + */ + 'isHidden': boolean; + /** + * + * @type {string} + * @memberof ExpandedPersonResponseDto + */ + 'name': string; + /** + * + * @type {string} + * @memberof ExpandedPersonResponseDto + */ + 'thumbnailPath': string; + /** + * + * @type {number} + * @memberof ExpandedPersonResponseDto + */ + 'x1': number; + /** + * + * @type {number} + * @memberof ExpandedPersonResponseDto + */ + 'x2': number; + /** + * + * @type {number} + * @memberof ExpandedPersonResponseDto + */ + 'y1': number; + /** + * + * @type {number} + * @memberof ExpandedPersonResponseDto + */ + 'y2': number; +} /** * * @export