1
0
mirror of https://github.com/immich-app/immich.git synced 2025-07-15 07:14:42 +02:00

feat: sync implementation for the user entity (#16234)

* ci: print out typeorm generation changes

* feat: sync implementation for the user entity

wip

---------

Co-authored-by: Jason Rasmussen <jason@rasm.me>
This commit is contained in:
Zack Pollard
2025-02-21 04:37:57 +00:00
committed by GitHub
parent 02cd8da871
commit ac36effb45
38 changed files with 1774 additions and 10 deletions

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

107
mobile/openapi/lib/model/sync_ack_dto.dart generated Normal file
View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

127
mobile/openapi/lib/model/sync_user_v1.dart generated Normal file
View File

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