mirror of
https://github.com/immich-app/immich
synced 2025-10-17 18:19:27 +00:00
Merge a3c0acf9a5 into e7d6a066f8
This commit is contained in:
commit
57e8617633
12 changed files with 219 additions and 101 deletions
1
mobile/openapi/README.md
generated
1
mobile/openapi/README.md
generated
|
|
@ -402,6 +402,7 @@ Class | Method | HTTP request | Description
|
||||||
- [MemoriesUpdate](doc//MemoriesUpdate.md)
|
- [MemoriesUpdate](doc//MemoriesUpdate.md)
|
||||||
- [MemoryCreateDto](doc//MemoryCreateDto.md)
|
- [MemoryCreateDto](doc//MemoryCreateDto.md)
|
||||||
- [MemoryResponseDto](doc//MemoryResponseDto.md)
|
- [MemoryResponseDto](doc//MemoryResponseDto.md)
|
||||||
|
- [MemorySearchOrder](doc//MemorySearchOrder.md)
|
||||||
- [MemoryStatisticsResponseDto](doc//MemoryStatisticsResponseDto.md)
|
- [MemoryStatisticsResponseDto](doc//MemoryStatisticsResponseDto.md)
|
||||||
- [MemoryType](doc//MemoryType.md)
|
- [MemoryType](doc//MemoryType.md)
|
||||||
- [MemoryUpdateDto](doc//MemoryUpdateDto.md)
|
- [MemoryUpdateDto](doc//MemoryUpdateDto.md)
|
||||||
|
|
|
||||||
1
mobile/openapi/lib/api.dart
generated
1
mobile/openapi/lib/api.dart
generated
|
|
@ -173,6 +173,7 @@ part 'model/memories_response.dart';
|
||||||
part 'model/memories_update.dart';
|
part 'model/memories_update.dart';
|
||||||
part 'model/memory_create_dto.dart';
|
part 'model/memory_create_dto.dart';
|
||||||
part 'model/memory_response_dto.dart';
|
part 'model/memory_response_dto.dart';
|
||||||
|
part 'model/memory_search_order.dart';
|
||||||
part 'model/memory_statistics_response_dto.dart';
|
part 'model/memory_statistics_response_dto.dart';
|
||||||
part 'model/memory_type.dart';
|
part 'model/memory_type.dart';
|
||||||
part 'model/memory_update_dto.dart';
|
part 'model/memory_update_dto.dart';
|
||||||
|
|
|
||||||
44
mobile/openapi/lib/api/memories_api.dart
generated
44
mobile/openapi/lib/api/memories_api.dart
generated
|
|
@ -238,8 +238,13 @@ class MemoriesApi {
|
||||||
///
|
///
|
||||||
/// * [bool] isTrashed:
|
/// * [bool] isTrashed:
|
||||||
///
|
///
|
||||||
|
/// * [MemorySearchOrder] order:
|
||||||
|
///
|
||||||
|
/// * [int] size:
|
||||||
|
/// Number of memories to return
|
||||||
|
///
|
||||||
/// * [MemoryType] type:
|
/// * [MemoryType] type:
|
||||||
Future<Response> memoriesStatisticsWithHttpInfo({ DateTime? for_, bool? isSaved, bool? isTrashed, MemoryType? type, }) async {
|
Future<Response> memoriesStatisticsWithHttpInfo({ DateTime? for_, bool? isSaved, bool? isTrashed, MemorySearchOrder? order, int? size, MemoryType? type, }) async {
|
||||||
// ignore: prefer_const_declarations
|
// ignore: prefer_const_declarations
|
||||||
final apiPath = r'/memories/statistics';
|
final apiPath = r'/memories/statistics';
|
||||||
|
|
||||||
|
|
@ -259,6 +264,12 @@ class MemoriesApi {
|
||||||
if (isTrashed != null) {
|
if (isTrashed != null) {
|
||||||
queryParams.addAll(_queryParams('', 'isTrashed', isTrashed));
|
queryParams.addAll(_queryParams('', 'isTrashed', isTrashed));
|
||||||
}
|
}
|
||||||
|
if (order != null) {
|
||||||
|
queryParams.addAll(_queryParams('', 'order', order));
|
||||||
|
}
|
||||||
|
if (size != null) {
|
||||||
|
queryParams.addAll(_queryParams('', 'size', size));
|
||||||
|
}
|
||||||
if (type != null) {
|
if (type != null) {
|
||||||
queryParams.addAll(_queryParams('', 'type', type));
|
queryParams.addAll(_queryParams('', 'type', type));
|
||||||
}
|
}
|
||||||
|
|
@ -287,9 +298,14 @@ class MemoriesApi {
|
||||||
///
|
///
|
||||||
/// * [bool] isTrashed:
|
/// * [bool] isTrashed:
|
||||||
///
|
///
|
||||||
|
/// * [MemorySearchOrder] order:
|
||||||
|
///
|
||||||
|
/// * [int] size:
|
||||||
|
/// Number of memories to return
|
||||||
|
///
|
||||||
/// * [MemoryType] type:
|
/// * [MemoryType] type:
|
||||||
Future<MemoryStatisticsResponseDto?> memoriesStatistics({ DateTime? for_, bool? isSaved, bool? isTrashed, MemoryType? type, }) async {
|
Future<MemoryStatisticsResponseDto?> memoriesStatistics({ DateTime? for_, bool? isSaved, bool? isTrashed, MemorySearchOrder? order, int? size, MemoryType? type, }) async {
|
||||||
final response = await memoriesStatisticsWithHttpInfo( for_: for_, isSaved: isSaved, isTrashed: isTrashed, type: type, );
|
final response = await memoriesStatisticsWithHttpInfo( for_: for_, isSaved: isSaved, isTrashed: isTrashed, order: order, size: size, type: type, );
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
|
|
@ -375,8 +391,13 @@ class MemoriesApi {
|
||||||
///
|
///
|
||||||
/// * [bool] isTrashed:
|
/// * [bool] isTrashed:
|
||||||
///
|
///
|
||||||
|
/// * [MemorySearchOrder] order:
|
||||||
|
///
|
||||||
|
/// * [int] size:
|
||||||
|
/// Number of memories to return
|
||||||
|
///
|
||||||
/// * [MemoryType] type:
|
/// * [MemoryType] type:
|
||||||
Future<Response> searchMemoriesWithHttpInfo({ DateTime? for_, bool? isSaved, bool? isTrashed, MemoryType? type, }) async {
|
Future<Response> searchMemoriesWithHttpInfo({ DateTime? for_, bool? isSaved, bool? isTrashed, MemorySearchOrder? order, int? size, MemoryType? type, }) async {
|
||||||
// ignore: prefer_const_declarations
|
// ignore: prefer_const_declarations
|
||||||
final apiPath = r'/memories';
|
final apiPath = r'/memories';
|
||||||
|
|
||||||
|
|
@ -396,6 +417,12 @@ class MemoriesApi {
|
||||||
if (isTrashed != null) {
|
if (isTrashed != null) {
|
||||||
queryParams.addAll(_queryParams('', 'isTrashed', isTrashed));
|
queryParams.addAll(_queryParams('', 'isTrashed', isTrashed));
|
||||||
}
|
}
|
||||||
|
if (order != null) {
|
||||||
|
queryParams.addAll(_queryParams('', 'order', order));
|
||||||
|
}
|
||||||
|
if (size != null) {
|
||||||
|
queryParams.addAll(_queryParams('', 'size', size));
|
||||||
|
}
|
||||||
if (type != null) {
|
if (type != null) {
|
||||||
queryParams.addAll(_queryParams('', 'type', type));
|
queryParams.addAll(_queryParams('', 'type', type));
|
||||||
}
|
}
|
||||||
|
|
@ -424,9 +451,14 @@ class MemoriesApi {
|
||||||
///
|
///
|
||||||
/// * [bool] isTrashed:
|
/// * [bool] isTrashed:
|
||||||
///
|
///
|
||||||
|
/// * [MemorySearchOrder] order:
|
||||||
|
///
|
||||||
|
/// * [int] size:
|
||||||
|
/// Number of memories to return
|
||||||
|
///
|
||||||
/// * [MemoryType] type:
|
/// * [MemoryType] type:
|
||||||
Future<List<MemoryResponseDto>?> searchMemories({ DateTime? for_, bool? isSaved, bool? isTrashed, MemoryType? type, }) async {
|
Future<List<MemoryResponseDto>?> searchMemories({ DateTime? for_, bool? isSaved, bool? isTrashed, MemorySearchOrder? order, int? size, MemoryType? type, }) async {
|
||||||
final response = await searchMemoriesWithHttpInfo( for_: for_, isSaved: isSaved, isTrashed: isTrashed, type: type, );
|
final response = await searchMemoriesWithHttpInfo( for_: for_, isSaved: isSaved, isTrashed: isTrashed, order: order, size: size, type: type, );
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
2
mobile/openapi/lib/api_client.dart
generated
2
mobile/openapi/lib/api_client.dart
generated
|
|
@ -400,6 +400,8 @@ class ApiClient {
|
||||||
return MemoryCreateDto.fromJson(value);
|
return MemoryCreateDto.fromJson(value);
|
||||||
case 'MemoryResponseDto':
|
case 'MemoryResponseDto':
|
||||||
return MemoryResponseDto.fromJson(value);
|
return MemoryResponseDto.fromJson(value);
|
||||||
|
case 'MemorySearchOrder':
|
||||||
|
return MemorySearchOrderTypeTransformer().decode(value);
|
||||||
case 'MemoryStatisticsResponseDto':
|
case 'MemoryStatisticsResponseDto':
|
||||||
return MemoryStatisticsResponseDto.fromJson(value);
|
return MemoryStatisticsResponseDto.fromJson(value);
|
||||||
case 'MemoryType':
|
case 'MemoryType':
|
||||||
|
|
|
||||||
3
mobile/openapi/lib/api_helper.dart
generated
3
mobile/openapi/lib/api_helper.dart
generated
|
|
@ -106,6 +106,9 @@ String parameterToString(dynamic value) {
|
||||||
if (value is ManualJobName) {
|
if (value is ManualJobName) {
|
||||||
return ManualJobNameTypeTransformer().encode(value).toString();
|
return ManualJobNameTypeTransformer().encode(value).toString();
|
||||||
}
|
}
|
||||||
|
if (value is MemorySearchOrder) {
|
||||||
|
return MemorySearchOrderTypeTransformer().encode(value).toString();
|
||||||
|
}
|
||||||
if (value is MemoryType) {
|
if (value is MemoryType) {
|
||||||
return MemoryTypeTypeTransformer().encode(value).toString();
|
return MemoryTypeTypeTransformer().encode(value).toString();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
70
mobile/openapi/lib/model/memory_response_dto.dart
generated
70
mobile/openapi/lib/model/memory_response_dto.dart
generated
|
|
@ -16,14 +16,10 @@ class MemoryResponseDto {
|
||||||
this.assets = const [],
|
this.assets = const [],
|
||||||
required this.createdAt,
|
required this.createdAt,
|
||||||
required this.data,
|
required this.data,
|
||||||
this.deletedAt,
|
|
||||||
this.hideAt,
|
|
||||||
required this.id,
|
required this.id,
|
||||||
required this.isSaved,
|
required this.isSaved,
|
||||||
required this.memoryAt,
|
required this.memoryAt,
|
||||||
required this.ownerId,
|
required this.ownerId,
|
||||||
this.seenAt,
|
|
||||||
this.showAt,
|
|
||||||
required this.type,
|
required this.type,
|
||||||
required this.updatedAt,
|
required this.updatedAt,
|
||||||
});
|
});
|
||||||
|
|
@ -34,22 +30,6 @@ class MemoryResponseDto {
|
||||||
|
|
||||||
OnThisDayDto data;
|
OnThisDayDto data;
|
||||||
|
|
||||||
///
|
|
||||||
/// 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.
|
|
||||||
///
|
|
||||||
DateTime? deletedAt;
|
|
||||||
|
|
||||||
///
|
|
||||||
/// 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.
|
|
||||||
///
|
|
||||||
DateTime? hideAt;
|
|
||||||
|
|
||||||
String id;
|
String id;
|
||||||
|
|
||||||
bool isSaved;
|
bool isSaved;
|
||||||
|
|
@ -58,22 +38,6 @@ class MemoryResponseDto {
|
||||||
|
|
||||||
String ownerId;
|
String ownerId;
|
||||||
|
|
||||||
///
|
|
||||||
/// 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.
|
|
||||||
///
|
|
||||||
DateTime? seenAt;
|
|
||||||
|
|
||||||
///
|
|
||||||
/// 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.
|
|
||||||
///
|
|
||||||
DateTime? showAt;
|
|
||||||
|
|
||||||
MemoryType type;
|
MemoryType type;
|
||||||
|
|
||||||
DateTime updatedAt;
|
DateTime updatedAt;
|
||||||
|
|
@ -83,14 +47,10 @@ class MemoryResponseDto {
|
||||||
_deepEquality.equals(other.assets, assets) &&
|
_deepEquality.equals(other.assets, assets) &&
|
||||||
other.createdAt == createdAt &&
|
other.createdAt == createdAt &&
|
||||||
other.data == data &&
|
other.data == data &&
|
||||||
other.deletedAt == deletedAt &&
|
|
||||||
other.hideAt == hideAt &&
|
|
||||||
other.id == id &&
|
other.id == id &&
|
||||||
other.isSaved == isSaved &&
|
other.isSaved == isSaved &&
|
||||||
other.memoryAt == memoryAt &&
|
other.memoryAt == memoryAt &&
|
||||||
other.ownerId == ownerId &&
|
other.ownerId == ownerId &&
|
||||||
other.seenAt == seenAt &&
|
|
||||||
other.showAt == showAt &&
|
|
||||||
other.type == type &&
|
other.type == type &&
|
||||||
other.updatedAt == updatedAt;
|
other.updatedAt == updatedAt;
|
||||||
|
|
||||||
|
|
@ -100,49 +60,25 @@ class MemoryResponseDto {
|
||||||
(assets.hashCode) +
|
(assets.hashCode) +
|
||||||
(createdAt.hashCode) +
|
(createdAt.hashCode) +
|
||||||
(data.hashCode) +
|
(data.hashCode) +
|
||||||
(deletedAt == null ? 0 : deletedAt!.hashCode) +
|
|
||||||
(hideAt == null ? 0 : hideAt!.hashCode) +
|
|
||||||
(id.hashCode) +
|
(id.hashCode) +
|
||||||
(isSaved.hashCode) +
|
(isSaved.hashCode) +
|
||||||
(memoryAt.hashCode) +
|
(memoryAt.hashCode) +
|
||||||
(ownerId.hashCode) +
|
(ownerId.hashCode) +
|
||||||
(seenAt == null ? 0 : seenAt!.hashCode) +
|
|
||||||
(showAt == null ? 0 : showAt!.hashCode) +
|
|
||||||
(type.hashCode) +
|
(type.hashCode) +
|
||||||
(updatedAt.hashCode);
|
(updatedAt.hashCode);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() => 'MemoryResponseDto[assets=$assets, createdAt=$createdAt, data=$data, deletedAt=$deletedAt, hideAt=$hideAt, id=$id, isSaved=$isSaved, memoryAt=$memoryAt, ownerId=$ownerId, seenAt=$seenAt, showAt=$showAt, type=$type, updatedAt=$updatedAt]';
|
String toString() => 'MemoryResponseDto[assets=$assets, createdAt=$createdAt, data=$data, id=$id, isSaved=$isSaved, memoryAt=$memoryAt, ownerId=$ownerId, type=$type, updatedAt=$updatedAt]';
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
Map<String, dynamic> toJson() {
|
||||||
final json = <String, dynamic>{};
|
final json = <String, dynamic>{};
|
||||||
json[r'assets'] = this.assets;
|
json[r'assets'] = this.assets;
|
||||||
json[r'createdAt'] = this.createdAt.toUtc().toIso8601String();
|
json[r'createdAt'] = this.createdAt.toUtc().toIso8601String();
|
||||||
json[r'data'] = this.data;
|
json[r'data'] = this.data;
|
||||||
if (this.deletedAt != null) {
|
|
||||||
json[r'deletedAt'] = this.deletedAt!.toUtc().toIso8601String();
|
|
||||||
} else {
|
|
||||||
// json[r'deletedAt'] = null;
|
|
||||||
}
|
|
||||||
if (this.hideAt != null) {
|
|
||||||
json[r'hideAt'] = this.hideAt!.toUtc().toIso8601String();
|
|
||||||
} else {
|
|
||||||
// json[r'hideAt'] = null;
|
|
||||||
}
|
|
||||||
json[r'id'] = this.id;
|
json[r'id'] = this.id;
|
||||||
json[r'isSaved'] = this.isSaved;
|
json[r'isSaved'] = this.isSaved;
|
||||||
json[r'memoryAt'] = this.memoryAt.toUtc().toIso8601String();
|
json[r'memoryAt'] = this.memoryAt.toUtc().toIso8601String();
|
||||||
json[r'ownerId'] = this.ownerId;
|
json[r'ownerId'] = this.ownerId;
|
||||||
if (this.seenAt != null) {
|
|
||||||
json[r'seenAt'] = this.seenAt!.toUtc().toIso8601String();
|
|
||||||
} else {
|
|
||||||
// json[r'seenAt'] = null;
|
|
||||||
}
|
|
||||||
if (this.showAt != null) {
|
|
||||||
json[r'showAt'] = this.showAt!.toUtc().toIso8601String();
|
|
||||||
} else {
|
|
||||||
// json[r'showAt'] = null;
|
|
||||||
}
|
|
||||||
json[r'type'] = this.type;
|
json[r'type'] = this.type;
|
||||||
json[r'updatedAt'] = this.updatedAt.toUtc().toIso8601String();
|
json[r'updatedAt'] = this.updatedAt.toUtc().toIso8601String();
|
||||||
return json;
|
return json;
|
||||||
|
|
@ -160,14 +96,10 @@ class MemoryResponseDto {
|
||||||
assets: AssetResponseDto.listFromJson(json[r'assets']),
|
assets: AssetResponseDto.listFromJson(json[r'assets']),
|
||||||
createdAt: mapDateTime(json, r'createdAt', r'')!,
|
createdAt: mapDateTime(json, r'createdAt', r'')!,
|
||||||
data: OnThisDayDto.fromJson(json[r'data'])!,
|
data: OnThisDayDto.fromJson(json[r'data'])!,
|
||||||
deletedAt: mapDateTime(json, r'deletedAt', r''),
|
|
||||||
hideAt: mapDateTime(json, r'hideAt', r''),
|
|
||||||
id: mapValueOfType<String>(json, r'id')!,
|
id: mapValueOfType<String>(json, r'id')!,
|
||||||
isSaved: mapValueOfType<bool>(json, r'isSaved')!,
|
isSaved: mapValueOfType<bool>(json, r'isSaved')!,
|
||||||
memoryAt: mapDateTime(json, r'memoryAt', r'')!,
|
memoryAt: mapDateTime(json, r'memoryAt', r'')!,
|
||||||
ownerId: mapValueOfType<String>(json, r'ownerId')!,
|
ownerId: mapValueOfType<String>(json, r'ownerId')!,
|
||||||
seenAt: mapDateTime(json, r'seenAt', r''),
|
|
||||||
showAt: mapDateTime(json, r'showAt', r''),
|
|
||||||
type: MemoryType.fromJson(json[r'type'])!,
|
type: MemoryType.fromJson(json[r'type'])!,
|
||||||
updatedAt: mapDateTime(json, r'updatedAt', r'')!,
|
updatedAt: mapDateTime(json, r'updatedAt', r'')!,
|
||||||
);
|
);
|
||||||
|
|
|
||||||
88
mobile/openapi/lib/model/memory_search_order.dart
generated
Normal file
88
mobile/openapi/lib/model/memory_search_order.dart
generated
Normal file
|
|
@ -0,0 +1,88 @@
|
||||||
|
//
|
||||||
|
// 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 MemorySearchOrder {
|
||||||
|
/// Instantiate a new enum with the provided [value].
|
||||||
|
const MemorySearchOrder._(this.value);
|
||||||
|
|
||||||
|
/// The underlying value of this enum member.
|
||||||
|
final String value;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() => value;
|
||||||
|
|
||||||
|
String toJson() => value;
|
||||||
|
|
||||||
|
static const asc = MemorySearchOrder._(r'asc');
|
||||||
|
static const desc = MemorySearchOrder._(r'desc');
|
||||||
|
static const random = MemorySearchOrder._(r'random');
|
||||||
|
|
||||||
|
/// List of all possible values in this [enum][MemorySearchOrder].
|
||||||
|
static const values = <MemorySearchOrder>[
|
||||||
|
asc,
|
||||||
|
desc,
|
||||||
|
random,
|
||||||
|
];
|
||||||
|
|
||||||
|
static MemorySearchOrder? fromJson(dynamic value) => MemorySearchOrderTypeTransformer().decode(value);
|
||||||
|
|
||||||
|
static List<MemorySearchOrder> listFromJson(dynamic json, {bool growable = false,}) {
|
||||||
|
final result = <MemorySearchOrder>[];
|
||||||
|
if (json is List && json.isNotEmpty) {
|
||||||
|
for (final row in json) {
|
||||||
|
final value = MemorySearchOrder.fromJson(row);
|
||||||
|
if (value != null) {
|
||||||
|
result.add(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result.toList(growable: growable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Transformation class that can [encode] an instance of [MemorySearchOrder] to String,
|
||||||
|
/// and [decode] dynamic data back to [MemorySearchOrder].
|
||||||
|
class MemorySearchOrderTypeTransformer {
|
||||||
|
factory MemorySearchOrderTypeTransformer() => _instance ??= const MemorySearchOrderTypeTransformer._();
|
||||||
|
|
||||||
|
const MemorySearchOrderTypeTransformer._();
|
||||||
|
|
||||||
|
String encode(MemorySearchOrder data) => data.value;
|
||||||
|
|
||||||
|
/// Decodes a [dynamic value][data] to a MemorySearchOrder.
|
||||||
|
///
|
||||||
|
/// 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.
|
||||||
|
MemorySearchOrder? decode(dynamic data, {bool allowNull = true}) {
|
||||||
|
if (data != null) {
|
||||||
|
switch (data) {
|
||||||
|
case r'asc': return MemorySearchOrder.asc;
|
||||||
|
case r'desc': return MemorySearchOrder.desc;
|
||||||
|
case r'random': return MemorySearchOrder.random;
|
||||||
|
default:
|
||||||
|
if (!allowNull) {
|
||||||
|
throw ArgumentError('Unknown enum value to decode: $data');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Singleton [MemorySearchOrderTypeTransformer] instance.
|
||||||
|
static MemorySearchOrderTypeTransformer? _instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -4136,6 +4136,24 @@
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "order",
|
||||||
|
"required": false,
|
||||||
|
"in": "query",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/MemorySearchOrder"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "size",
|
||||||
|
"required": false,
|
||||||
|
"in": "query",
|
||||||
|
"description": "Number of memories to return",
|
||||||
|
"schema": {
|
||||||
|
"minimum": 1,
|
||||||
|
"type": "integer"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "type",
|
"name": "type",
|
||||||
"required": false,
|
"required": false,
|
||||||
|
|
@ -4249,6 +4267,24 @@
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "order",
|
||||||
|
"required": false,
|
||||||
|
"in": "query",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/MemorySearchOrder"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "size",
|
||||||
|
"required": false,
|
||||||
|
"in": "query",
|
||||||
|
"description": "Number of memories to return",
|
||||||
|
"schema": {
|
||||||
|
"minimum": 1,
|
||||||
|
"type": "integer"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "type",
|
"name": "type",
|
||||||
"required": false,
|
"required": false,
|
||||||
|
|
@ -12441,14 +12477,6 @@
|
||||||
"data": {
|
"data": {
|
||||||
"$ref": "#/components/schemas/OnThisDayDto"
|
"$ref": "#/components/schemas/OnThisDayDto"
|
||||||
},
|
},
|
||||||
"deletedAt": {
|
|
||||||
"format": "date-time",
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"hideAt": {
|
|
||||||
"format": "date-time",
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"id": {
|
"id": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
|
@ -12462,14 +12490,6 @@
|
||||||
"ownerId": {
|
"ownerId": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"seenAt": {
|
|
||||||
"format": "date-time",
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"showAt": {
|
|
||||||
"format": "date-time",
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"type": {
|
"type": {
|
||||||
"allOf": [
|
"allOf": [
|
||||||
{
|
{
|
||||||
|
|
@ -12495,6 +12515,14 @@
|
||||||
],
|
],
|
||||||
"type": "object"
|
"type": "object"
|
||||||
},
|
},
|
||||||
|
"MemorySearchOrder": {
|
||||||
|
"enum": [
|
||||||
|
"asc",
|
||||||
|
"desc",
|
||||||
|
"random"
|
||||||
|
],
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"MemoryStatisticsResponseDto": {
|
"MemoryStatisticsResponseDto": {
|
||||||
"properties": {
|
"properties": {
|
||||||
"total": {
|
"total": {
|
||||||
|
|
|
||||||
|
|
@ -758,14 +758,10 @@ export type MemoryResponseDto = {
|
||||||
assets: AssetResponseDto[];
|
assets: AssetResponseDto[];
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
data: OnThisDayDto;
|
data: OnThisDayDto;
|
||||||
deletedAt?: string;
|
|
||||||
hideAt?: string;
|
|
||||||
id: string;
|
id: string;
|
||||||
isSaved: boolean;
|
isSaved: boolean;
|
||||||
memoryAt: string;
|
memoryAt: string;
|
||||||
ownerId: string;
|
ownerId: string;
|
||||||
seenAt?: string;
|
|
||||||
showAt?: string;
|
|
||||||
"type": MemoryType;
|
"type": MemoryType;
|
||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
};
|
};
|
||||||
|
|
@ -2863,10 +2859,12 @@ export function reverseGeocode({ lat, lon }: {
|
||||||
/**
|
/**
|
||||||
* This endpoint requires the `memory.read` permission.
|
* This endpoint requires the `memory.read` permission.
|
||||||
*/
|
*/
|
||||||
export function searchMemories({ $for, isSaved, isTrashed, $type }: {
|
export function searchMemories({ $for, isSaved, isTrashed, order, size, $type }: {
|
||||||
$for?: string;
|
$for?: string;
|
||||||
isSaved?: boolean;
|
isSaved?: boolean;
|
||||||
isTrashed?: boolean;
|
isTrashed?: boolean;
|
||||||
|
order?: MemorySearchOrder;
|
||||||
|
size?: number;
|
||||||
$type?: MemoryType;
|
$type?: MemoryType;
|
||||||
}, opts?: Oazapfts.RequestOpts) {
|
}, opts?: Oazapfts.RequestOpts) {
|
||||||
return oazapfts.ok(oazapfts.fetchJson<{
|
return oazapfts.ok(oazapfts.fetchJson<{
|
||||||
|
|
@ -2876,6 +2874,8 @@ export function searchMemories({ $for, isSaved, isTrashed, $type }: {
|
||||||
"for": $for,
|
"for": $for,
|
||||||
isSaved,
|
isSaved,
|
||||||
isTrashed,
|
isTrashed,
|
||||||
|
order,
|
||||||
|
size,
|
||||||
"type": $type
|
"type": $type
|
||||||
}))}`, {
|
}))}`, {
|
||||||
...opts
|
...opts
|
||||||
|
|
@ -2899,10 +2899,12 @@ export function createMemory({ memoryCreateDto }: {
|
||||||
/**
|
/**
|
||||||
* This endpoint requires the `memory.statistics` permission.
|
* This endpoint requires the `memory.statistics` permission.
|
||||||
*/
|
*/
|
||||||
export function memoriesStatistics({ $for, isSaved, isTrashed, $type }: {
|
export function memoriesStatistics({ $for, isSaved, isTrashed, order, size, $type }: {
|
||||||
$for?: string;
|
$for?: string;
|
||||||
isSaved?: boolean;
|
isSaved?: boolean;
|
||||||
isTrashed?: boolean;
|
isTrashed?: boolean;
|
||||||
|
order?: MemorySearchOrder;
|
||||||
|
size?: number;
|
||||||
$type?: MemoryType;
|
$type?: MemoryType;
|
||||||
}, opts?: Oazapfts.RequestOpts) {
|
}, opts?: Oazapfts.RequestOpts) {
|
||||||
return oazapfts.ok(oazapfts.fetchJson<{
|
return oazapfts.ok(oazapfts.fetchJson<{
|
||||||
|
|
@ -2912,6 +2914,8 @@ export function memoriesStatistics({ $for, isSaved, isTrashed, $type }: {
|
||||||
"for": $for,
|
"for": $for,
|
||||||
isSaved,
|
isSaved,
|
||||||
isTrashed,
|
isTrashed,
|
||||||
|
order,
|
||||||
|
size,
|
||||||
"type": $type
|
"type": $type
|
||||||
}))}`, {
|
}))}`, {
|
||||||
...opts
|
...opts
|
||||||
|
|
@ -4891,6 +4895,11 @@ export enum JobCommand {
|
||||||
Empty = "empty",
|
Empty = "empty",
|
||||||
ClearFailed = "clear-failed"
|
ClearFailed = "clear-failed"
|
||||||
}
|
}
|
||||||
|
export enum MemorySearchOrder {
|
||||||
|
Asc = "asc",
|
||||||
|
Desc = "desc",
|
||||||
|
Random = "random"
|
||||||
|
}
|
||||||
export enum MemoryType {
|
export enum MemoryType {
|
||||||
OnThisDay = "on_this_day"
|
OnThisDay = "on_this_day"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import { IsInt, IsObject, IsPositive, ValidateNested } from 'class-validator';
|
||||||
import { Memory } from 'src/database';
|
import { Memory } from 'src/database';
|
||||||
import { AssetResponseDto, mapAsset } from 'src/dtos/asset-response.dto';
|
import { AssetResponseDto, mapAsset } from 'src/dtos/asset-response.dto';
|
||||||
import { AuthDto } from 'src/dtos/auth.dto';
|
import { AuthDto } from 'src/dtos/auth.dto';
|
||||||
import { MemoryType } from 'src/enum';
|
import { AssetOrderWithRandom, MemoryType } from 'src/enum';
|
||||||
import { ValidateBoolean, ValidateDate, ValidateEnum, ValidateUUID } from 'src/validation';
|
import { ValidateBoolean, ValidateDate, ValidateEnum, ValidateUUID } from 'src/validation';
|
||||||
|
|
||||||
class MemoryBaseDto {
|
class MemoryBaseDto {
|
||||||
|
|
@ -27,6 +27,15 @@ export class MemorySearchDto {
|
||||||
|
|
||||||
@ValidateBoolean({ optional: true })
|
@ValidateBoolean({ optional: true })
|
||||||
isSaved?: boolean;
|
isSaved?: boolean;
|
||||||
|
|
||||||
|
@IsInt()
|
||||||
|
@IsPositive()
|
||||||
|
@Type(() => Number)
|
||||||
|
@ApiProperty({ type: 'integer', description: 'Number of memories to return' })
|
||||||
|
size?: number;
|
||||||
|
|
||||||
|
@ValidateEnum({ enum: AssetOrderWithRandom, name: 'MemorySearchOrder', optional: true, default: AssetOrderWithRandom.Desc })
|
||||||
|
order?: AssetOrderWithRandom;
|
||||||
}
|
}
|
||||||
|
|
||||||
class OnThisDayDto {
|
class OnThisDayDto {
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,14 @@ export enum MemoryType {
|
||||||
OnThisDay = 'on_this_day',
|
OnThisDay = 'on_this_day',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum AssetOrderWithRandom {
|
||||||
|
// Include existing values
|
||||||
|
Asc = AssetOrder.Asc,
|
||||||
|
Desc = AssetOrder.Desc,
|
||||||
|
/** Randomly Ordered */
|
||||||
|
Random = 'random',
|
||||||
|
}
|
||||||
|
|
||||||
export enum Permission {
|
export enum Permission {
|
||||||
All = 'all',
|
All = 'all',
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { Insertable, Kysely, sql, Updateable } from 'kysely';
|
import { Insertable, Kysely, OrderByDirection, sql, Updateable } from 'kysely';
|
||||||
import { jsonArrayFrom } from 'kysely/helpers/postgres';
|
import { jsonArrayFrom } from 'kysely/helpers/postgres';
|
||||||
import { DateTime } from 'luxon';
|
import { DateTime } from 'luxon';
|
||||||
import { InjectKysely } from 'nestjs-kysely';
|
import { InjectKysely } from 'nestjs-kysely';
|
||||||
import { Chunked, ChunkedSet, DummyValue, GenerateSql } from 'src/decorators';
|
import { Chunked, ChunkedSet, DummyValue, GenerateSql } from 'src/decorators';
|
||||||
import { MemorySearchDto } from 'src/dtos/memory.dto';
|
import { MemorySearchDto } from 'src/dtos/memory.dto';
|
||||||
import { AssetVisibility } from 'src/enum';
|
import { AssetOrderWithRandom, AssetVisibility } from 'src/enum';
|
||||||
import { DB } from 'src/schema';
|
import { DB } from 'src/schema';
|
||||||
import { MemoryTable } from 'src/schema/tables/memory.table';
|
import { MemoryTable } from 'src/schema/tables/memory.table';
|
||||||
import { IBulkAsset } from 'src/types';
|
import { IBulkAsset } from 'src/types';
|
||||||
|
|
@ -72,7 +72,12 @@ export class MemoryRepository implements IBulkAsset {
|
||||||
).as('assets'),
|
).as('assets'),
|
||||||
)
|
)
|
||||||
.selectAll('memory')
|
.selectAll('memory')
|
||||||
.orderBy('memoryAt', 'desc')
|
.$call((qb) =>
|
||||||
|
dto.order === AssetOrderWithRandom.Random
|
||||||
|
? qb.orderBy(sql`RANDOM()`)
|
||||||
|
: qb.orderBy('memoryAt', (dto.order?.toLowerCase() || 'desc') as OrderByDirection),
|
||||||
|
)
|
||||||
|
.$if(dto.size !== undefined, (qb) => qb.limit(dto.size!))
|
||||||
.execute();
|
.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue