mirror of
https://github.com/immich-app/immich
synced 2025-06-09 09:36:56 +00:00
chore: add missing api properties on sync enums (#18916)
Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
This commit is contained in:
parent
2da94439c7
commit
70b9a4c8f1
@ -7,6 +7,7 @@ import 'package:immich_mobile/infrastructure/entities/remote_asset.entity.drift.
|
|||||||
import 'package:immich_mobile/infrastructure/entities/user.entity.drift.dart';
|
import 'package:immich_mobile/infrastructure/entities/user.entity.drift.dart';
|
||||||
import 'package:immich_mobile/infrastructure/repositories/db.repository.dart';
|
import 'package:immich_mobile/infrastructure/repositories/db.repository.dart';
|
||||||
import 'package:logging/logging.dart';
|
import 'package:logging/logging.dart';
|
||||||
|
import 'package:openapi/api.dart' as api show AssetVisibility;
|
||||||
import 'package:openapi/api.dart' hide AssetVisibility;
|
import 'package:openapi/api.dart' hide AssetVisibility;
|
||||||
|
|
||||||
class DriftSyncStreamRepository extends DriftDatabaseRepository
|
class DriftSyncStreamRepository extends DriftDatabaseRepository
|
||||||
@ -231,22 +232,22 @@ class DriftSyncStreamRepository extends DriftDatabaseRepository
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
extension on SyncAssetV1TypeEnum {
|
extension on AssetTypeEnum {
|
||||||
AssetType toAssetType() => switch (this) {
|
AssetType toAssetType() => switch (this) {
|
||||||
SyncAssetV1TypeEnum.IMAGE => AssetType.image,
|
AssetTypeEnum.IMAGE => AssetType.image,
|
||||||
SyncAssetV1TypeEnum.VIDEO => AssetType.video,
|
AssetTypeEnum.VIDEO => AssetType.video,
|
||||||
SyncAssetV1TypeEnum.AUDIO => AssetType.audio,
|
AssetTypeEnum.AUDIO => AssetType.audio,
|
||||||
SyncAssetV1TypeEnum.OTHER => AssetType.other,
|
AssetTypeEnum.OTHER => AssetType.other,
|
||||||
_ => throw Exception('Unknown SyncAssetV1TypeEnum value: $this'),
|
_ => throw Exception('Unknown AssetType value: $this'),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
extension on SyncAssetV1VisibilityEnum {
|
extension on api.AssetVisibility {
|
||||||
AssetVisibility toAssetVisibility() => switch (this) {
|
AssetVisibility toAssetVisibility() => switch (this) {
|
||||||
SyncAssetV1VisibilityEnum.timeline => AssetVisibility.timeline,
|
api.AssetVisibility.timeline => AssetVisibility.timeline,
|
||||||
SyncAssetV1VisibilityEnum.hidden => AssetVisibility.hidden,
|
api.AssetVisibility.hidden => AssetVisibility.hidden,
|
||||||
SyncAssetV1VisibilityEnum.archive => AssetVisibility.archive,
|
api.AssetVisibility.archive => AssetVisibility.archive,
|
||||||
SyncAssetV1VisibilityEnum.locked => AssetVisibility.locked,
|
api.AssetVisibility.locked => AssetVisibility.locked,
|
||||||
_ => throw Exception('Unknown SyncAssetV1VisibilityEnum value: $this'),
|
_ => throw Exception('Unknown AssetVisibility value: $this'),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
78
mobile/openapi/lib/model/sync_album_user_v1.dart
generated
78
mobile/openapi/lib/model/sync_album_user_v1.dart
generated
@ -20,7 +20,7 @@ class SyncAlbumUserV1 {
|
|||||||
|
|
||||||
String albumId;
|
String albumId;
|
||||||
|
|
||||||
SyncAlbumUserV1RoleEnum role;
|
AlbumUserRole role;
|
||||||
|
|
||||||
String userId;
|
String userId;
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ class SyncAlbumUserV1 {
|
|||||||
|
|
||||||
return SyncAlbumUserV1(
|
return SyncAlbumUserV1(
|
||||||
albumId: mapValueOfType<String>(json, r'albumId')!,
|
albumId: mapValueOfType<String>(json, r'albumId')!,
|
||||||
role: SyncAlbumUserV1RoleEnum.fromJson(json[r'role'])!,
|
role: AlbumUserRole.fromJson(json[r'role'])!,
|
||||||
userId: mapValueOfType<String>(json, r'userId')!,
|
userId: mapValueOfType<String>(json, r'userId')!,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -113,77 +113,3 @@ class SyncAlbumUserV1 {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class SyncAlbumUserV1RoleEnum {
|
|
||||||
/// Instantiate a new enum with the provided [value].
|
|
||||||
const SyncAlbumUserV1RoleEnum._(this.value);
|
|
||||||
|
|
||||||
/// The underlying value of this enum member.
|
|
||||||
final String value;
|
|
||||||
|
|
||||||
@override
|
|
||||||
String toString() => value;
|
|
||||||
|
|
||||||
String toJson() => value;
|
|
||||||
|
|
||||||
static const editor = SyncAlbumUserV1RoleEnum._(r'editor');
|
|
||||||
static const viewer = SyncAlbumUserV1RoleEnum._(r'viewer');
|
|
||||||
|
|
||||||
/// List of all possible values in this [enum][SyncAlbumUserV1RoleEnum].
|
|
||||||
static const values = <SyncAlbumUserV1RoleEnum>[
|
|
||||||
editor,
|
|
||||||
viewer,
|
|
||||||
];
|
|
||||||
|
|
||||||
static SyncAlbumUserV1RoleEnum? fromJson(dynamic value) => SyncAlbumUserV1RoleEnumTypeTransformer().decode(value);
|
|
||||||
|
|
||||||
static List<SyncAlbumUserV1RoleEnum> listFromJson(dynamic json, {bool growable = false,}) {
|
|
||||||
final result = <SyncAlbumUserV1RoleEnum>[];
|
|
||||||
if (json is List && json.isNotEmpty) {
|
|
||||||
for (final row in json) {
|
|
||||||
final value = SyncAlbumUserV1RoleEnum.fromJson(row);
|
|
||||||
if (value != null) {
|
|
||||||
result.add(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result.toList(growable: growable);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Transformation class that can [encode] an instance of [SyncAlbumUserV1RoleEnum] to String,
|
|
||||||
/// and [decode] dynamic data back to [SyncAlbumUserV1RoleEnum].
|
|
||||||
class SyncAlbumUserV1RoleEnumTypeTransformer {
|
|
||||||
factory SyncAlbumUserV1RoleEnumTypeTransformer() => _instance ??= const SyncAlbumUserV1RoleEnumTypeTransformer._();
|
|
||||||
|
|
||||||
const SyncAlbumUserV1RoleEnumTypeTransformer._();
|
|
||||||
|
|
||||||
String encode(SyncAlbumUserV1RoleEnum data) => data.value;
|
|
||||||
|
|
||||||
/// Decodes a [dynamic value][data] to a SyncAlbumUserV1RoleEnum.
|
|
||||||
///
|
|
||||||
/// 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.
|
|
||||||
SyncAlbumUserV1RoleEnum? decode(dynamic data, {bool allowNull = true}) {
|
|
||||||
if (data != null) {
|
|
||||||
switch (data) {
|
|
||||||
case r'editor': return SyncAlbumUserV1RoleEnum.editor;
|
|
||||||
case r'viewer': return SyncAlbumUserV1RoleEnum.viewer;
|
|
||||||
default:
|
|
||||||
if (!allowNull) {
|
|
||||||
throw ArgumentError('Unknown enum value to decode: $data');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Singleton [SyncAlbumUserV1RoleEnumTypeTransformer] instance.
|
|
||||||
static SyncAlbumUserV1RoleEnumTypeTransformer? _instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
168
mobile/openapi/lib/model/sync_asset_v1.dart
generated
168
mobile/openapi/lib/model/sync_asset_v1.dart
generated
@ -47,9 +47,9 @@ class SyncAssetV1 {
|
|||||||
|
|
||||||
String? thumbhash;
|
String? thumbhash;
|
||||||
|
|
||||||
SyncAssetV1TypeEnum type;
|
AssetTypeEnum type;
|
||||||
|
|
||||||
SyncAssetV1VisibilityEnum visibility;
|
AssetVisibility visibility;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool operator ==(Object other) => identical(this, other) || other is SyncAssetV1 &&
|
bool operator ==(Object other) => identical(this, other) || other is SyncAssetV1 &&
|
||||||
@ -141,8 +141,8 @@ class SyncAssetV1 {
|
|||||||
originalFileName: mapValueOfType<String>(json, r'originalFileName')!,
|
originalFileName: mapValueOfType<String>(json, r'originalFileName')!,
|
||||||
ownerId: mapValueOfType<String>(json, r'ownerId')!,
|
ownerId: mapValueOfType<String>(json, r'ownerId')!,
|
||||||
thumbhash: mapValueOfType<String>(json, r'thumbhash'),
|
thumbhash: mapValueOfType<String>(json, r'thumbhash'),
|
||||||
type: SyncAssetV1TypeEnum.fromJson(json[r'type'])!,
|
type: AssetTypeEnum.fromJson(json[r'type'])!,
|
||||||
visibility: SyncAssetV1VisibilityEnum.fromJson(json[r'visibility'])!,
|
visibility: AssetVisibility.fromJson(json[r'visibility'])!,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -205,163 +205,3 @@ class SyncAssetV1 {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class SyncAssetV1TypeEnum {
|
|
||||||
/// Instantiate a new enum with the provided [value].
|
|
||||||
const SyncAssetV1TypeEnum._(this.value);
|
|
||||||
|
|
||||||
/// The underlying value of this enum member.
|
|
||||||
final String value;
|
|
||||||
|
|
||||||
@override
|
|
||||||
String toString() => value;
|
|
||||||
|
|
||||||
String toJson() => value;
|
|
||||||
|
|
||||||
static const IMAGE = SyncAssetV1TypeEnum._(r'IMAGE');
|
|
||||||
static const VIDEO = SyncAssetV1TypeEnum._(r'VIDEO');
|
|
||||||
static const AUDIO = SyncAssetV1TypeEnum._(r'AUDIO');
|
|
||||||
static const OTHER = SyncAssetV1TypeEnum._(r'OTHER');
|
|
||||||
|
|
||||||
/// List of all possible values in this [enum][SyncAssetV1TypeEnum].
|
|
||||||
static const values = <SyncAssetV1TypeEnum>[
|
|
||||||
IMAGE,
|
|
||||||
VIDEO,
|
|
||||||
AUDIO,
|
|
||||||
OTHER,
|
|
||||||
];
|
|
||||||
|
|
||||||
static SyncAssetV1TypeEnum? fromJson(dynamic value) => SyncAssetV1TypeEnumTypeTransformer().decode(value);
|
|
||||||
|
|
||||||
static List<SyncAssetV1TypeEnum> listFromJson(dynamic json, {bool growable = false,}) {
|
|
||||||
final result = <SyncAssetV1TypeEnum>[];
|
|
||||||
if (json is List && json.isNotEmpty) {
|
|
||||||
for (final row in json) {
|
|
||||||
final value = SyncAssetV1TypeEnum.fromJson(row);
|
|
||||||
if (value != null) {
|
|
||||||
result.add(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result.toList(growable: growable);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Transformation class that can [encode] an instance of [SyncAssetV1TypeEnum] to String,
|
|
||||||
/// and [decode] dynamic data back to [SyncAssetV1TypeEnum].
|
|
||||||
class SyncAssetV1TypeEnumTypeTransformer {
|
|
||||||
factory SyncAssetV1TypeEnumTypeTransformer() => _instance ??= const SyncAssetV1TypeEnumTypeTransformer._();
|
|
||||||
|
|
||||||
const SyncAssetV1TypeEnumTypeTransformer._();
|
|
||||||
|
|
||||||
String encode(SyncAssetV1TypeEnum data) => data.value;
|
|
||||||
|
|
||||||
/// Decodes a [dynamic value][data] to a SyncAssetV1TypeEnum.
|
|
||||||
///
|
|
||||||
/// 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.
|
|
||||||
SyncAssetV1TypeEnum? decode(dynamic data, {bool allowNull = true}) {
|
|
||||||
if (data != null) {
|
|
||||||
switch (data) {
|
|
||||||
case r'IMAGE': return SyncAssetV1TypeEnum.IMAGE;
|
|
||||||
case r'VIDEO': return SyncAssetV1TypeEnum.VIDEO;
|
|
||||||
case r'AUDIO': return SyncAssetV1TypeEnum.AUDIO;
|
|
||||||
case r'OTHER': return SyncAssetV1TypeEnum.OTHER;
|
|
||||||
default:
|
|
||||||
if (!allowNull) {
|
|
||||||
throw ArgumentError('Unknown enum value to decode: $data');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Singleton [SyncAssetV1TypeEnumTypeTransformer] instance.
|
|
||||||
static SyncAssetV1TypeEnumTypeTransformer? _instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class SyncAssetV1VisibilityEnum {
|
|
||||||
/// Instantiate a new enum with the provided [value].
|
|
||||||
const SyncAssetV1VisibilityEnum._(this.value);
|
|
||||||
|
|
||||||
/// The underlying value of this enum member.
|
|
||||||
final String value;
|
|
||||||
|
|
||||||
@override
|
|
||||||
String toString() => value;
|
|
||||||
|
|
||||||
String toJson() => value;
|
|
||||||
|
|
||||||
static const archive = SyncAssetV1VisibilityEnum._(r'archive');
|
|
||||||
static const timeline = SyncAssetV1VisibilityEnum._(r'timeline');
|
|
||||||
static const hidden = SyncAssetV1VisibilityEnum._(r'hidden');
|
|
||||||
static const locked = SyncAssetV1VisibilityEnum._(r'locked');
|
|
||||||
|
|
||||||
/// List of all possible values in this [enum][SyncAssetV1VisibilityEnum].
|
|
||||||
static const values = <SyncAssetV1VisibilityEnum>[
|
|
||||||
archive,
|
|
||||||
timeline,
|
|
||||||
hidden,
|
|
||||||
locked,
|
|
||||||
];
|
|
||||||
|
|
||||||
static SyncAssetV1VisibilityEnum? fromJson(dynamic value) => SyncAssetV1VisibilityEnumTypeTransformer().decode(value);
|
|
||||||
|
|
||||||
static List<SyncAssetV1VisibilityEnum> listFromJson(dynamic json, {bool growable = false,}) {
|
|
||||||
final result = <SyncAssetV1VisibilityEnum>[];
|
|
||||||
if (json is List && json.isNotEmpty) {
|
|
||||||
for (final row in json) {
|
|
||||||
final value = SyncAssetV1VisibilityEnum.fromJson(row);
|
|
||||||
if (value != null) {
|
|
||||||
result.add(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result.toList(growable: growable);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Transformation class that can [encode] an instance of [SyncAssetV1VisibilityEnum] to String,
|
|
||||||
/// and [decode] dynamic data back to [SyncAssetV1VisibilityEnum].
|
|
||||||
class SyncAssetV1VisibilityEnumTypeTransformer {
|
|
||||||
factory SyncAssetV1VisibilityEnumTypeTransformer() => _instance ??= const SyncAssetV1VisibilityEnumTypeTransformer._();
|
|
||||||
|
|
||||||
const SyncAssetV1VisibilityEnumTypeTransformer._();
|
|
||||||
|
|
||||||
String encode(SyncAssetV1VisibilityEnum data) => data.value;
|
|
||||||
|
|
||||||
/// Decodes a [dynamic value][data] to a SyncAssetV1VisibilityEnum.
|
|
||||||
///
|
|
||||||
/// 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.
|
|
||||||
SyncAssetV1VisibilityEnum? decode(dynamic data, {bool allowNull = true}) {
|
|
||||||
if (data != null) {
|
|
||||||
switch (data) {
|
|
||||||
case r'archive': return SyncAssetV1VisibilityEnum.archive;
|
|
||||||
case r'timeline': return SyncAssetV1VisibilityEnum.timeline;
|
|
||||||
case r'hidden': return SyncAssetV1VisibilityEnum.hidden;
|
|
||||||
case r'locked': return SyncAssetV1VisibilityEnum.locked;
|
|
||||||
default:
|
|
||||||
if (!allowNull) {
|
|
||||||
throw ArgumentError('Unknown enum value to decode: $data');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Singleton [SyncAssetV1VisibilityEnumTypeTransformer] instance.
|
|
||||||
static SyncAssetV1VisibilityEnumTypeTransformer? _instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -12988,11 +12988,11 @@
|
|||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"role": {
|
"role": {
|
||||||
"enum": [
|
"allOf": [
|
||||||
"editor",
|
{
|
||||||
"viewer"
|
"$ref": "#/components/schemas/AlbumUserRole"
|
||||||
],
|
}
|
||||||
"type": "string"
|
]
|
||||||
},
|
},
|
||||||
"userId": {
|
"userId": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
@ -13241,22 +13241,18 @@
|
|||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"type": {
|
"type": {
|
||||||
"enum": [
|
"allOf": [
|
||||||
"IMAGE",
|
{
|
||||||
"VIDEO",
|
"$ref": "#/components/schemas/AssetTypeEnum"
|
||||||
"AUDIO",
|
}
|
||||||
"OTHER"
|
]
|
||||||
],
|
|
||||||
"type": "string"
|
|
||||||
},
|
},
|
||||||
"visibility": {
|
"visibility": {
|
||||||
"enum": [
|
"allOf": [
|
||||||
"archive",
|
{
|
||||||
"timeline",
|
"$ref": "#/components/schemas/AssetVisibility"
|
||||||
"hidden",
|
}
|
||||||
"locked"
|
]
|
||||||
],
|
|
||||||
"type": "string"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
|
@ -65,9 +65,11 @@ export class SyncAssetV1 {
|
|||||||
fileCreatedAt!: Date | null;
|
fileCreatedAt!: Date | null;
|
||||||
fileModifiedAt!: Date | null;
|
fileModifiedAt!: Date | null;
|
||||||
localDateTime!: Date | null;
|
localDateTime!: Date | null;
|
||||||
|
@ApiProperty({ enumName: 'AssetTypeEnum', enum: AssetType })
|
||||||
type!: AssetType;
|
type!: AssetType;
|
||||||
deletedAt!: Date | null;
|
deletedAt!: Date | null;
|
||||||
isFavorite!: boolean;
|
isFavorite!: boolean;
|
||||||
|
@ApiProperty({ enumName: 'AssetVisibility', enum: AssetVisibility })
|
||||||
visibility!: AssetVisibility;
|
visibility!: AssetVisibility;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,6 +127,7 @@ export class SyncAlbumUserDeleteV1 {
|
|||||||
export class SyncAlbumUserV1 {
|
export class SyncAlbumUserV1 {
|
||||||
albumId!: string;
|
albumId!: string;
|
||||||
userId!: string;
|
userId!: string;
|
||||||
|
@ApiProperty({ enumName: 'AlbumUserRole', enum: AlbumUserRole })
|
||||||
role!: AlbumUserRole;
|
role!: AlbumUserRole;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user