From d1fb292055cb00109afe72759b27006d40f02c8d Mon Sep 17 00:00:00 2001 From: izzy Date: Mon, 12 Jan 2026 13:50:36 +0000 Subject: [PATCH] fix: annotate oneOf in open api schema --- mobile/openapi/README.md | 8 ++ mobile/openapi/lib/api.dart | 8 ++ mobile/openapi/lib/api_client.dart | 16 +++ mobile/openapi/lib/model/base_job_data.dart | 108 +++++++++++++++ .../lib/model/job_database_backup.dart | 107 +++++++++++++++ .../openapi/lib/model/job_memory_cleanup.dart | 107 +++++++++++++++ .../lib/model/job_memory_generate.dart | 107 +++++++++++++++ .../openapi/lib/model/job_person_cleanup.dart | 107 +++++++++++++++ mobile/openapi/lib/model/job_tag_cleanup.dart | 107 +++++++++++++++ .../lib/model/job_user_delete_check.dart | 107 +++++++++++++++ .../lib/model/queue_job_create_dto.dart | 4 +- .../lib/model/queue_job_create_dto_job.dart | 107 +++++++++++++++ open-api/immich-openapi-specs.json | 125 +++++++++++++++++- open-api/typescript-sdk/src/fetch-client.ts | 31 ++++- server/src/dtos/queue.dto.ts | 6 +- 15 files changed, 1050 insertions(+), 5 deletions(-) create mode 100644 mobile/openapi/lib/model/base_job_data.dart create mode 100644 mobile/openapi/lib/model/job_database_backup.dart create mode 100644 mobile/openapi/lib/model/job_memory_cleanup.dart create mode 100644 mobile/openapi/lib/model/job_memory_generate.dart create mode 100644 mobile/openapi/lib/model/job_person_cleanup.dart create mode 100644 mobile/openapi/lib/model/job_tag_cleanup.dart create mode 100644 mobile/openapi/lib/model/job_user_delete_check.dart create mode 100644 mobile/openapi/lib/model/queue_job_create_dto_job.dart diff --git a/mobile/openapi/README.md b/mobile/openapi/README.md index b32403edab..f22a4e7395 100644 --- a/mobile/openapi/README.md +++ b/mobile/openapi/README.md @@ -389,6 +389,7 @@ Class | Method | HTTP request | Description - [AudioCodec](doc//AudioCodec.md) - [AuthStatusResponseDto](doc//AuthStatusResponseDto.md) - [AvatarUpdate](doc//AvatarUpdate.md) + - [BaseJobData](doc//BaseJobData.md) - [BulkIdErrorReason](doc//BulkIdErrorReason.md) - [BulkIdResponseDto](doc//BulkIdResponseDto.md) - [BulkIdsDto](doc//BulkIdsDto.md) @@ -422,8 +423,14 @@ Class | Method | HTTP request | Description - [FoldersUpdate](doc//FoldersUpdate.md) - [ImageFormat](doc//ImageFormat.md) - [JobCreateDto](doc//JobCreateDto.md) + - [JobDatabaseBackup](doc//JobDatabaseBackup.md) + - [JobMemoryCleanup](doc//JobMemoryCleanup.md) + - [JobMemoryGenerate](doc//JobMemoryGenerate.md) - [JobName](doc//JobName.md) + - [JobPersonCleanup](doc//JobPersonCleanup.md) - [JobSettingsDto](doc//JobSettingsDto.md) + - [JobTagCleanup](doc//JobTagCleanup.md) + - [JobUserDeleteCheck](doc//JobUserDeleteCheck.md) - [LibraryResponseDto](doc//LibraryResponseDto.md) - [LibraryStatsResponseDto](doc//LibraryStatsResponseDto.md) - [LicenseKeyDto](doc//LicenseKeyDto.md) @@ -497,6 +504,7 @@ Class | Method | HTTP request | Description - [QueueCommandDto](doc//QueueCommandDto.md) - [QueueDeleteDto](doc//QueueDeleteDto.md) - [QueueJobCreateDto](doc//QueueJobCreateDto.md) + - [QueueJobCreateDtoJob](doc//QueueJobCreateDtoJob.md) - [QueueJobResponseDto](doc//QueueJobResponseDto.md) - [QueueJobStatus](doc//QueueJobStatus.md) - [QueueName](doc//QueueName.md) diff --git a/mobile/openapi/lib/api.dart b/mobile/openapi/lib/api.dart index bbdc4b0463..5ebcb64b11 100644 --- a/mobile/openapi/lib/api.dart +++ b/mobile/openapi/lib/api.dart @@ -134,6 +134,7 @@ part 'model/asset_visibility.dart'; part 'model/audio_codec.dart'; part 'model/auth_status_response_dto.dart'; part 'model/avatar_update.dart'; +part 'model/base_job_data.dart'; part 'model/bulk_id_error_reason.dart'; part 'model/bulk_id_response_dto.dart'; part 'model/bulk_ids_dto.dart'; @@ -167,8 +168,14 @@ part 'model/folders_response.dart'; part 'model/folders_update.dart'; part 'model/image_format.dart'; part 'model/job_create_dto.dart'; +part 'model/job_database_backup.dart'; +part 'model/job_memory_cleanup.dart'; +part 'model/job_memory_generate.dart'; part 'model/job_name.dart'; +part 'model/job_person_cleanup.dart'; part 'model/job_settings_dto.dart'; +part 'model/job_tag_cleanup.dart'; +part 'model/job_user_delete_check.dart'; part 'model/library_response_dto.dart'; part 'model/library_stats_response_dto.dart'; part 'model/license_key_dto.dart'; @@ -242,6 +249,7 @@ part 'model/queue_command.dart'; part 'model/queue_command_dto.dart'; part 'model/queue_delete_dto.dart'; part 'model/queue_job_create_dto.dart'; +part 'model/queue_job_create_dto_job.dart'; part 'model/queue_job_response_dto.dart'; part 'model/queue_job_status.dart'; part 'model/queue_name.dart'; diff --git a/mobile/openapi/lib/api_client.dart b/mobile/openapi/lib/api_client.dart index ffd77e0dcd..38abf7d481 100644 --- a/mobile/openapi/lib/api_client.dart +++ b/mobile/openapi/lib/api_client.dart @@ -316,6 +316,8 @@ class ApiClient { return AuthStatusResponseDto.fromJson(value); case 'AvatarUpdate': return AvatarUpdate.fromJson(value); + case 'BaseJobData': + return BaseJobData.fromJson(value); case 'BulkIdErrorReason': return BulkIdErrorReasonTypeTransformer().decode(value); case 'BulkIdResponseDto': @@ -382,10 +384,22 @@ class ApiClient { return ImageFormatTypeTransformer().decode(value); case 'JobCreateDto': return JobCreateDto.fromJson(value); + case 'JobDatabaseBackup': + return JobDatabaseBackup.fromJson(value); + case 'JobMemoryCleanup': + return JobMemoryCleanup.fromJson(value); + case 'JobMemoryGenerate': + return JobMemoryGenerate.fromJson(value); case 'JobName': return JobNameTypeTransformer().decode(value); + case 'JobPersonCleanup': + return JobPersonCleanup.fromJson(value); case 'JobSettingsDto': return JobSettingsDto.fromJson(value); + case 'JobTagCleanup': + return JobTagCleanup.fromJson(value); + case 'JobUserDeleteCheck': + return JobUserDeleteCheck.fromJson(value); case 'LibraryResponseDto': return LibraryResponseDto.fromJson(value); case 'LibraryStatsResponseDto': @@ -532,6 +546,8 @@ class ApiClient { return QueueDeleteDto.fromJson(value); case 'QueueJobCreateDto': return QueueJobCreateDto.fromJson(value); + case 'QueueJobCreateDtoJob': + return QueueJobCreateDtoJob.fromJson(value); case 'QueueJobResponseDto': return QueueJobResponseDto.fromJson(value); case 'QueueJobStatus': diff --git a/mobile/openapi/lib/model/base_job_data.dart b/mobile/openapi/lib/model/base_job_data.dart new file mode 100644 index 0000000000..f8dd50c3b1 --- /dev/null +++ b/mobile/openapi/lib/model/base_job_data.dart @@ -0,0 +1,108 @@ +// +// 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 BaseJobData { + /// Returns a new [BaseJobData] instance. + BaseJobData({ + this.force, + }); + + /// + /// 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. + /// + bool? force; + + @override + bool operator ==(Object other) => identical(this, other) || other is BaseJobData && + other.force == force; + + @override + int get hashCode => + // ignore: unnecessary_parenthesis + (force == null ? 0 : force!.hashCode); + + @override + String toString() => 'BaseJobData[force=$force]'; + + Map toJson() { + final json = {}; + if (this.force != null) { + json[r'force'] = this.force; + } else { + // json[r'force'] = null; + } + return json; + } + + /// Returns a new [BaseJobData] instance and imports its values from + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static BaseJobData? fromJson(dynamic value) { + upgradeDto(value, "BaseJobData"); + if (value is Map) { + final json = value.cast(); + + return BaseJobData( + force: mapValueOfType(json, r'force'), + ); + } + 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 = BaseJobData.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 = BaseJobData.fromJson(entry.value); + if (value != null) { + map[entry.key] = value; + } + } + } + return map; + } + + // maps a json object with a list of BaseJobData-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] = BaseJobData.listFromJson(entry.value, growable: growable,); + } + } + return map; + } + + /// The list of required keys that must be present in a JSON. + static const requiredKeys = { + }; +} + diff --git a/mobile/openapi/lib/model/job_database_backup.dart b/mobile/openapi/lib/model/job_database_backup.dart new file mode 100644 index 0000000000..80060400ef --- /dev/null +++ b/mobile/openapi/lib/model/job_database_backup.dart @@ -0,0 +1,107 @@ +// +// 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 JobDatabaseBackup { + /// Returns a new [JobDatabaseBackup] instance. + JobDatabaseBackup({ + required this.data, + required this.name, + }); + + BaseJobData data; + + num name; + + @override + bool operator ==(Object other) => identical(this, other) || other is JobDatabaseBackup && + other.data == data && + other.name == name; + + @override + int get hashCode => + // ignore: unnecessary_parenthesis + (data.hashCode) + + (name.hashCode); + + @override + String toString() => 'JobDatabaseBackup[data=$data, name=$name]'; + + Map toJson() { + final json = {}; + json[r'data'] = this.data; + json[r'name'] = this.name; + return json; + } + + /// Returns a new [JobDatabaseBackup] instance and imports its values from + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static JobDatabaseBackup? fromJson(dynamic value) { + upgradeDto(value, "JobDatabaseBackup"); + if (value is Map) { + final json = value.cast(); + + return JobDatabaseBackup( + data: BaseJobData.fromJson(json[r'data'])!, + name: num.parse('${json[r'name']}'), + ); + } + 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 = JobDatabaseBackup.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 = JobDatabaseBackup.fromJson(entry.value); + if (value != null) { + map[entry.key] = value; + } + } + } + return map; + } + + // maps a json object with a list of JobDatabaseBackup-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] = JobDatabaseBackup.listFromJson(entry.value, growable: growable,); + } + } + return map; + } + + /// The list of required keys that must be present in a JSON. + static const requiredKeys = { + 'data', + 'name', + }; +} + diff --git a/mobile/openapi/lib/model/job_memory_cleanup.dart b/mobile/openapi/lib/model/job_memory_cleanup.dart new file mode 100644 index 0000000000..dff75ab50f --- /dev/null +++ b/mobile/openapi/lib/model/job_memory_cleanup.dart @@ -0,0 +1,107 @@ +// +// 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 JobMemoryCleanup { + /// Returns a new [JobMemoryCleanup] instance. + JobMemoryCleanup({ + required this.data, + required this.name, + }); + + BaseJobData data; + + num name; + + @override + bool operator ==(Object other) => identical(this, other) || other is JobMemoryCleanup && + other.data == data && + other.name == name; + + @override + int get hashCode => + // ignore: unnecessary_parenthesis + (data.hashCode) + + (name.hashCode); + + @override + String toString() => 'JobMemoryCleanup[data=$data, name=$name]'; + + Map toJson() { + final json = {}; + json[r'data'] = this.data; + json[r'name'] = this.name; + return json; + } + + /// Returns a new [JobMemoryCleanup] instance and imports its values from + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static JobMemoryCleanup? fromJson(dynamic value) { + upgradeDto(value, "JobMemoryCleanup"); + if (value is Map) { + final json = value.cast(); + + return JobMemoryCleanup( + data: BaseJobData.fromJson(json[r'data'])!, + name: num.parse('${json[r'name']}'), + ); + } + 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 = JobMemoryCleanup.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 = JobMemoryCleanup.fromJson(entry.value); + if (value != null) { + map[entry.key] = value; + } + } + } + return map; + } + + // maps a json object with a list of JobMemoryCleanup-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] = JobMemoryCleanup.listFromJson(entry.value, growable: growable,); + } + } + return map; + } + + /// The list of required keys that must be present in a JSON. + static const requiredKeys = { + 'data', + 'name', + }; +} + diff --git a/mobile/openapi/lib/model/job_memory_generate.dart b/mobile/openapi/lib/model/job_memory_generate.dart new file mode 100644 index 0000000000..37d4d24be6 --- /dev/null +++ b/mobile/openapi/lib/model/job_memory_generate.dart @@ -0,0 +1,107 @@ +// +// 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 JobMemoryGenerate { + /// Returns a new [JobMemoryGenerate] instance. + JobMemoryGenerate({ + required this.data, + required this.name, + }); + + BaseJobData data; + + num name; + + @override + bool operator ==(Object other) => identical(this, other) || other is JobMemoryGenerate && + other.data == data && + other.name == name; + + @override + int get hashCode => + // ignore: unnecessary_parenthesis + (data.hashCode) + + (name.hashCode); + + @override + String toString() => 'JobMemoryGenerate[data=$data, name=$name]'; + + Map toJson() { + final json = {}; + json[r'data'] = this.data; + json[r'name'] = this.name; + return json; + } + + /// Returns a new [JobMemoryGenerate] instance and imports its values from + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static JobMemoryGenerate? fromJson(dynamic value) { + upgradeDto(value, "JobMemoryGenerate"); + if (value is Map) { + final json = value.cast(); + + return JobMemoryGenerate( + data: BaseJobData.fromJson(json[r'data'])!, + name: num.parse('${json[r'name']}'), + ); + } + 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 = JobMemoryGenerate.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 = JobMemoryGenerate.fromJson(entry.value); + if (value != null) { + map[entry.key] = value; + } + } + } + return map; + } + + // maps a json object with a list of JobMemoryGenerate-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] = JobMemoryGenerate.listFromJson(entry.value, growable: growable,); + } + } + return map; + } + + /// The list of required keys that must be present in a JSON. + static const requiredKeys = { + 'data', + 'name', + }; +} + diff --git a/mobile/openapi/lib/model/job_person_cleanup.dart b/mobile/openapi/lib/model/job_person_cleanup.dart new file mode 100644 index 0000000000..d97df0d52e --- /dev/null +++ b/mobile/openapi/lib/model/job_person_cleanup.dart @@ -0,0 +1,107 @@ +// +// 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 JobPersonCleanup { + /// Returns a new [JobPersonCleanup] instance. + JobPersonCleanup({ + required this.data, + required this.name, + }); + + BaseJobData data; + + num name; + + @override + bool operator ==(Object other) => identical(this, other) || other is JobPersonCleanup && + other.data == data && + other.name == name; + + @override + int get hashCode => + // ignore: unnecessary_parenthesis + (data.hashCode) + + (name.hashCode); + + @override + String toString() => 'JobPersonCleanup[data=$data, name=$name]'; + + Map toJson() { + final json = {}; + json[r'data'] = this.data; + json[r'name'] = this.name; + return json; + } + + /// Returns a new [JobPersonCleanup] instance and imports its values from + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static JobPersonCleanup? fromJson(dynamic value) { + upgradeDto(value, "JobPersonCleanup"); + if (value is Map) { + final json = value.cast(); + + return JobPersonCleanup( + data: BaseJobData.fromJson(json[r'data'])!, + name: num.parse('${json[r'name']}'), + ); + } + 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 = JobPersonCleanup.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 = JobPersonCleanup.fromJson(entry.value); + if (value != null) { + map[entry.key] = value; + } + } + } + return map; + } + + // maps a json object with a list of JobPersonCleanup-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] = JobPersonCleanup.listFromJson(entry.value, growable: growable,); + } + } + return map; + } + + /// The list of required keys that must be present in a JSON. + static const requiredKeys = { + 'data', + 'name', + }; +} + diff --git a/mobile/openapi/lib/model/job_tag_cleanup.dart b/mobile/openapi/lib/model/job_tag_cleanup.dart new file mode 100644 index 0000000000..0ade0baeb4 --- /dev/null +++ b/mobile/openapi/lib/model/job_tag_cleanup.dart @@ -0,0 +1,107 @@ +// +// 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 JobTagCleanup { + /// Returns a new [JobTagCleanup] instance. + JobTagCleanup({ + required this.data, + required this.name, + }); + + BaseJobData data; + + num name; + + @override + bool operator ==(Object other) => identical(this, other) || other is JobTagCleanup && + other.data == data && + other.name == name; + + @override + int get hashCode => + // ignore: unnecessary_parenthesis + (data.hashCode) + + (name.hashCode); + + @override + String toString() => 'JobTagCleanup[data=$data, name=$name]'; + + Map toJson() { + final json = {}; + json[r'data'] = this.data; + json[r'name'] = this.name; + return json; + } + + /// Returns a new [JobTagCleanup] instance and imports its values from + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static JobTagCleanup? fromJson(dynamic value) { + upgradeDto(value, "JobTagCleanup"); + if (value is Map) { + final json = value.cast(); + + return JobTagCleanup( + data: BaseJobData.fromJson(json[r'data'])!, + name: num.parse('${json[r'name']}'), + ); + } + 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 = JobTagCleanup.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 = JobTagCleanup.fromJson(entry.value); + if (value != null) { + map[entry.key] = value; + } + } + } + return map; + } + + // maps a json object with a list of JobTagCleanup-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] = JobTagCleanup.listFromJson(entry.value, growable: growable,); + } + } + return map; + } + + /// The list of required keys that must be present in a JSON. + static const requiredKeys = { + 'data', + 'name', + }; +} + diff --git a/mobile/openapi/lib/model/job_user_delete_check.dart b/mobile/openapi/lib/model/job_user_delete_check.dart new file mode 100644 index 0000000000..df6bfcd30f --- /dev/null +++ b/mobile/openapi/lib/model/job_user_delete_check.dart @@ -0,0 +1,107 @@ +// +// 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 JobUserDeleteCheck { + /// Returns a new [JobUserDeleteCheck] instance. + JobUserDeleteCheck({ + required this.data, + required this.name, + }); + + BaseJobData data; + + num name; + + @override + bool operator ==(Object other) => identical(this, other) || other is JobUserDeleteCheck && + other.data == data && + other.name == name; + + @override + int get hashCode => + // ignore: unnecessary_parenthesis + (data.hashCode) + + (name.hashCode); + + @override + String toString() => 'JobUserDeleteCheck[data=$data, name=$name]'; + + Map toJson() { + final json = {}; + json[r'data'] = this.data; + json[r'name'] = this.name; + return json; + } + + /// Returns a new [JobUserDeleteCheck] instance and imports its values from + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static JobUserDeleteCheck? fromJson(dynamic value) { + upgradeDto(value, "JobUserDeleteCheck"); + if (value is Map) { + final json = value.cast(); + + return JobUserDeleteCheck( + data: BaseJobData.fromJson(json[r'data'])!, + name: num.parse('${json[r'name']}'), + ); + } + 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 = JobUserDeleteCheck.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 = JobUserDeleteCheck.fromJson(entry.value); + if (value != null) { + map[entry.key] = value; + } + } + } + return map; + } + + // maps a json object with a list of JobUserDeleteCheck-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] = JobUserDeleteCheck.listFromJson(entry.value, growable: growable,); + } + } + return map; + } + + /// The list of required keys that must be present in a JSON. + static const requiredKeys = { + 'data', + 'name', + }; +} + diff --git a/mobile/openapi/lib/model/queue_job_create_dto.dart b/mobile/openapi/lib/model/queue_job_create_dto.dart index b26303471e..f9505ac710 100644 --- a/mobile/openapi/lib/model/queue_job_create_dto.dart +++ b/mobile/openapi/lib/model/queue_job_create_dto.dart @@ -16,7 +16,7 @@ class QueueJobCreateDto { required this.job, }); - Object job; + QueueJobCreateDtoJob job; @override bool operator ==(Object other) => identical(this, other) || other is QueueJobCreateDto && @@ -45,7 +45,7 @@ class QueueJobCreateDto { final json = value.cast(); return QueueJobCreateDto( - job: mapValueOfType(json, r'job')!, + job: QueueJobCreateDtoJob.fromJson(json[r'job'])!, ); } return null; diff --git a/mobile/openapi/lib/model/queue_job_create_dto_job.dart b/mobile/openapi/lib/model/queue_job_create_dto_job.dart new file mode 100644 index 0000000000..f4f70a4618 --- /dev/null +++ b/mobile/openapi/lib/model/queue_job_create_dto_job.dart @@ -0,0 +1,107 @@ +// +// 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 QueueJobCreateDtoJob { + /// Returns a new [QueueJobCreateDtoJob] instance. + QueueJobCreateDtoJob({ + required this.data, + required this.name, + }); + + BaseJobData data; + + num name; + + @override + bool operator ==(Object other) => identical(this, other) || other is QueueJobCreateDtoJob && + other.data == data && + other.name == name; + + @override + int get hashCode => + // ignore: unnecessary_parenthesis + (data.hashCode) + + (name.hashCode); + + @override + String toString() => 'QueueJobCreateDtoJob[data=$data, name=$name]'; + + Map toJson() { + final json = {}; + json[r'data'] = this.data; + json[r'name'] = this.name; + return json; + } + + /// Returns a new [QueueJobCreateDtoJob] instance and imports its values from + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static QueueJobCreateDtoJob? fromJson(dynamic value) { + upgradeDto(value, "QueueJobCreateDtoJob"); + if (value is Map) { + final json = value.cast(); + + return QueueJobCreateDtoJob( + data: BaseJobData.fromJson(json[r'data'])!, + name: num.parse('${json[r'name']}'), + ); + } + 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 = QueueJobCreateDtoJob.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 = QueueJobCreateDtoJob.fromJson(entry.value); + if (value != null) { + map[entry.key] = value; + } + } + } + return map; + } + + // maps a json object with a list of QueueJobCreateDtoJob-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] = QueueJobCreateDtoJob.listFromJson(entry.value, growable: growable,); + } + } + return map; + } + + /// The list of required keys that must be present in a JSON. + static const requiredKeys = { + 'data', + 'name', + }; +} + diff --git a/open-api/immich-openapi-specs.json b/open-api/immich-openapi-specs.json index 9323258a78..6c47bc7c16 100644 --- a/open-api/immich-openapi-specs.json +++ b/open-api/immich-openapi-specs.json @@ -16575,6 +16575,14 @@ }, "type": "object" }, + "BaseJobData": { + "properties": { + "force": { + "type": "boolean" + } + }, + "type": "object" + }, "BulkIdErrorReason": { "enum": [ "duplicate", @@ -17255,6 +17263,54 @@ ], "type": "object" }, + "JobDatabaseBackup": { + "properties": { + "data": { + "$ref": "#/components/schemas/BaseJobData" + }, + "name": { + "enum": [], + "type": "number" + } + }, + "required": [ + "data", + "name" + ], + "type": "object" + }, + "JobMemoryCleanup": { + "properties": { + "data": { + "$ref": "#/components/schemas/BaseJobData" + }, + "name": { + "enum": [], + "type": "number" + } + }, + "required": [ + "data", + "name" + ], + "type": "object" + }, + "JobMemoryGenerate": { + "properties": { + "data": { + "$ref": "#/components/schemas/BaseJobData" + }, + "name": { + "enum": [], + "type": "number" + } + }, + "required": [ + "data", + "name" + ], + "type": "object" + }, "JobName": { "enum": [ "AssetDelete", @@ -17316,6 +17372,22 @@ ], "type": "string" }, + "JobPersonCleanup": { + "properties": { + "data": { + "$ref": "#/components/schemas/BaseJobData" + }, + "name": { + "enum": [], + "type": "number" + } + }, + "required": [ + "data", + "name" + ], + "type": "object" + }, "JobSettingsDto": { "properties": { "concurrency": { @@ -17328,6 +17400,38 @@ ], "type": "object" }, + "JobTagCleanup": { + "properties": { + "data": { + "$ref": "#/components/schemas/BaseJobData" + }, + "name": { + "enum": [], + "type": "number" + } + }, + "required": [ + "data", + "name" + ], + "type": "object" + }, + "JobUserDeleteCheck": { + "properties": { + "data": { + "$ref": "#/components/schemas/BaseJobData" + }, + "name": { + "enum": [], + "type": "number" + } + }, + "required": [ + "data", + "name" + ], + "type": "object" + }, "LibraryResponseDto": { "properties": { "assetCount": { @@ -19188,7 +19292,26 @@ "QueueJobCreateDto": { "properties": { "job": { - "type": "object" + "oneOf": [ + { + "$ref": "#/components/schemas/JobTagCleanup" + }, + { + "$ref": "#/components/schemas/JobPersonCleanup" + }, + { + "$ref": "#/components/schemas/JobUserDeleteCheck" + }, + { + "$ref": "#/components/schemas/JobMemoryCleanup" + }, + { + "$ref": "#/components/schemas/JobMemoryGenerate" + }, + { + "$ref": "#/components/schemas/JobDatabaseBackup" + } + ] } }, "required": [ diff --git a/open-api/typescript-sdk/src/fetch-client.ts b/open-api/typescript-sdk/src/fetch-client.ts index be6d726af4..627d22e8d1 100644 --- a/open-api/typescript-sdk/src/fetch-client.ts +++ b/open-api/typescript-sdk/src/fetch-client.ts @@ -1038,8 +1038,35 @@ export type QueueResponseDto = { name: QueueName; statistics: QueueStatisticsDto; }; +export type BaseJobData = { + force?: boolean; +}; +export type JobTagCleanup = { + data: BaseJobData; + name: Name; +}; +export type JobPersonCleanup = { + data: BaseJobData; + name: Name; +}; +export type JobUserDeleteCheck = { + data: BaseJobData; + name: Name; +}; +export type JobMemoryCleanup = { + data: BaseJobData; + name: Name; +}; +export type JobMemoryGenerate = { + data: BaseJobData; + name: Name; +}; +export type JobDatabaseBackup = { + data: BaseJobData; + name: Name; +}; export type QueueJobCreateDto = { - job: object; + job: JobTagCleanup | JobPersonCleanup | JobUserDeleteCheck | JobMemoryCleanup | JobMemoryGenerate | JobDatabaseBackup; }; export type QueueUpdateDto = { isPaused?: boolean; @@ -5609,6 +5636,8 @@ export enum PluginTriggerType { AssetCreate = "AssetCreate", PersonRecognized = "PersonRecognized" } +export enum Name { +} export enum QueueJobStatus { Active = "active", Failed = "failed", diff --git a/server/src/dtos/queue.dto.ts b/server/src/dtos/queue.dto.ts index 90e5523668..95e922711c 100644 --- a/server/src/dtos/queue.dto.ts +++ b/server/src/dtos/queue.dto.ts @@ -1,4 +1,4 @@ -import { ApiProperty } from '@nestjs/swagger'; +import { ApiExtraModels, ApiProperty, getSchemaPath } from '@nestjs/swagger'; import { ClassConstructor, Transform, Type } from 'class-transformer'; import { Equals, IsBoolean, IsDefined, IsOptional, ValidateNested } from 'class-validator'; import { HistoryBuilder, Property } from 'src/decorators'; @@ -56,7 +56,11 @@ const JOB_MAP: Record> = { [JobName.DatabaseBackup]: JobDatabaseBackup, }; +@ApiExtraModels(...Object.values(JOB_MAP)) export class QueueJobCreateDto { + @ApiProperty({ + oneOf: Object.values(JOB_MAP).map((job) => ({ $ref: getSchemaPath(job) })), + }) @ValidateNested() @Transform(transformToOneOf(JOB_MAP)) @IsDefined({