1
0
mirror of https://github.com/immich-app/immich.git synced 2025-05-29 01:07:40 +02:00

refactor(server): use date type for entities (#2602)

This commit is contained in:
Michel Heusschen 2023-05-30 15:15:56 +02:00 committed by GitHub
parent 3d505e425d
commit 789e3e3924
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
49 changed files with 243 additions and 217 deletions

View File

@ -128,8 +128,8 @@ class Album {
final Album a = Album( final Album a = Album(
remoteId: dto.id, remoteId: dto.id,
name: dto.albumName, name: dto.albumName,
createdAt: DateTime.parse(dto.createdAt), createdAt: dto.createdAt,
modifiedAt: DateTime.parse(dto.updatedAt), modifiedAt: dto.updatedAt,
shared: dto.shared, shared: dto.shared,
); );
a.owner.value = await db.users.getById(dto.ownerId); a.owner.value = await db.users.getById(dto.ownerId);

View File

@ -22,9 +22,7 @@ class User {
User.fromDto(UserResponseDto dto) User.fromDto(UserResponseDto dto)
: id = dto.id, : id = dto.id,
updatedAt = dto.updatedAt != null updatedAt = dto.updatedAt,
? DateTime.parse(dto.updatedAt!).toUtc()
: DateTime.now().toUtc(),
email = dto.email, email = dto.email,
firstName = dto.firstName, firstName = dto.firstName,
lastName = dto.lastName, lastName = dto.lastName,

View File

@ -279,7 +279,7 @@ class SyncService {
album.name = dto.albumName; album.name = dto.albumName;
album.shared = dto.shared; album.shared = dto.shared;
album.modifiedAt = DateTime.parse(dto.updatedAt); album.modifiedAt = dto.updatedAt;
if (album.thumbnail.value?.remoteId != dto.albumThumbnailAssetId) { if (album.thumbnail.value?.remoteId != dto.albumThumbnailAssetId) {
album.thumbnail.value = await _db.assets album.thumbnail.value = await _db.assets
.where() .where()
@ -713,5 +713,5 @@ bool _hasAlbumResponseDtoChanged(AlbumResponseDto dto, Album a) {
dto.albumThumbnailAssetId != a.thumbnail.value?.remoteId || dto.albumThumbnailAssetId != a.thumbnail.value?.remoteId ||
dto.shared != a.shared || dto.shared != a.shared ||
dto.sharedUsers.length != a.sharedUsers.length || dto.sharedUsers.length != a.sharedUsers.length ||
!DateTime.parse(dto.updatedAt).isAtSameMomentAs(a.modifiedAt); !dto.updatedAt.isAtSameMomentAs(a.modifiedAt);
} }

View File

@ -10,8 +10,8 @@ Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
**id** | **String** | | **id** | **String** | |
**name** | **String** | | **name** | **String** | |
**createdAt** | **String** | | **createdAt** | [**DateTime**](DateTime.md) | |
**updatedAt** | **String** | | **updatedAt** | [**DateTime**](DateTime.md) | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -12,7 +12,7 @@ Name | Type | Description | Notes
**email** | **String** | | **email** | **String** | |
**firstName** | **String** | | **firstName** | **String** | |
**lastName** | **String** | | **lastName** | **String** | |
**createdAt** | **String** | | **createdAt** | [**DateTime**](DateTime.md) | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -12,8 +12,8 @@ Name | Type | Description | Notes
**id** | **String** | | **id** | **String** | |
**ownerId** | **String** | | **ownerId** | **String** | |
**albumName** | **String** | | **albumName** | **String** | |
**createdAt** | **String** | | **createdAt** | [**DateTime**](DateTime.md) | |
**updatedAt** | **String** | | **updatedAt** | [**DateTime**](DateTime.md) | |
**albumThumbnailAssetId** | **String** | | **albumThumbnailAssetId** | **String** | |
**shared** | **bool** | | **shared** | **bool** | |
**sharedUsers** | [**List<UserResponseDto>**](UserResponseDto.md) | | [default to const []] **sharedUsers** | [**List<UserResponseDto>**](UserResponseDto.md) | | [default to const []]

View File

@ -9,7 +9,7 @@ import 'package:openapi/api.dart';
Name | Type | Description | Notes Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
**assetIds** | **List<String>** | | [default to const []] **assetIds** | **List<String>** | | [default to const []]
**expiresAt** | **String** | | [optional] **expiresAt** | [**DateTime**](DateTime.md) | | [optional]
**allowUpload** | **bool** | | [optional] **allowUpload** | **bool** | | [optional]
**allowDownload** | **bool** | | [optional] **allowDownload** | **bool** | | [optional]
**showExif** | **bool** | | [optional] **showExif** | **bool** | | [optional]

View File

@ -9,7 +9,7 @@ import 'package:openapi/api.dart';
Name | Type | Description | Notes Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
**description** | **String** | | [optional] **description** | **String** | | [optional]
**expiresAt** | **String** | | [optional] **expiresAt** | [**DateTime**](DateTime.md) | | [optional]
**allowUpload** | **bool** | | [optional] **allowUpload** | **bool** | | [optional]
**allowDownload** | **bool** | | [optional] **allowDownload** | **bool** | | [optional]
**showExif** | **bool** | | [optional] **showExif** | **bool** | | [optional]

View File

@ -13,8 +13,8 @@ Name | Type | Description | Notes
**description** | **String** | | [optional] **description** | **String** | | [optional]
**userId** | **String** | | **userId** | **String** | |
**key** | **String** | | **key** | **String** | |
**createdAt** | **String** | | **createdAt** | [**DateTime**](DateTime.md) | |
**expiresAt** | **String** | | **expiresAt** | [**DateTime**](DateTime.md) | |
**assets** | [**List<AssetResponseDto>**](AssetResponseDto.md) | | [default to const []] **assets** | [**List<AssetResponseDto>**](AssetResponseDto.md) | | [default to const []]
**album** | [**AlbumResponseDto**](AlbumResponseDto.md) | | [optional] **album** | [**AlbumResponseDto**](AlbumResponseDto.md) | | [optional]
**allowUpload** | **bool** | | **allowUpload** | **bool** | |

View File

@ -13,12 +13,12 @@ Name | Type | Description | Notes
**firstName** | **String** | | **firstName** | **String** | |
**lastName** | **String** | | **lastName** | **String** | |
**storageLabel** | **String** | | **storageLabel** | **String** | |
**createdAt** | **String** | |
**profileImagePath** | **String** | | **profileImagePath** | **String** | |
**shouldChangePassword** | **bool** | | **shouldChangePassword** | **bool** | |
**isAdmin** | **bool** | | **isAdmin** | **bool** | |
**deletedAt** | [**DateTime**](DateTime.md) | | [optional] **createdAt** | [**DateTime**](DateTime.md) | |
**updatedAt** | **String** | | [optional] **deletedAt** | [**DateTime**](DateTime.md) | |
**updatedAt** | [**DateTime**](DateTime.md) | |
**oauthId** | **String** | | **oauthId** | **String** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -28,7 +28,7 @@ class AdminSignupResponseDto {
String lastName; String lastName;
String createdAt; DateTime createdAt;
@override @override
bool operator ==(Object other) => identical(this, other) || other is AdminSignupResponseDto && bool operator ==(Object other) => identical(this, other) || other is AdminSignupResponseDto &&
@ -56,7 +56,7 @@ class AdminSignupResponseDto {
json[r'email'] = this.email; json[r'email'] = this.email;
json[r'firstName'] = this.firstName; json[r'firstName'] = this.firstName;
json[r'lastName'] = this.lastName; json[r'lastName'] = this.lastName;
json[r'createdAt'] = this.createdAt; json[r'createdAt'] = this.createdAt.toUtc().toIso8601String();
return json; return json;
} }
@ -83,7 +83,7 @@ class AdminSignupResponseDto {
email: mapValueOfType<String>(json, r'email')!, email: mapValueOfType<String>(json, r'email')!,
firstName: mapValueOfType<String>(json, r'firstName')!, firstName: mapValueOfType<String>(json, r'firstName')!,
lastName: mapValueOfType<String>(json, r'lastName')!, lastName: mapValueOfType<String>(json, r'lastName')!,
createdAt: mapValueOfType<String>(json, r'createdAt')!, createdAt: mapDateTime(json, r'createdAt', '')!,
); );
} }
return null; return null;

View File

@ -34,9 +34,9 @@ class AlbumResponseDto {
String albumName; String albumName;
String createdAt; DateTime createdAt;
String updatedAt; DateTime updatedAt;
String? albumThumbnailAssetId; String? albumThumbnailAssetId;
@ -86,8 +86,8 @@ class AlbumResponseDto {
json[r'id'] = this.id; json[r'id'] = this.id;
json[r'ownerId'] = this.ownerId; json[r'ownerId'] = this.ownerId;
json[r'albumName'] = this.albumName; json[r'albumName'] = this.albumName;
json[r'createdAt'] = this.createdAt; json[r'createdAt'] = this.createdAt.toUtc().toIso8601String();
json[r'updatedAt'] = this.updatedAt; json[r'updatedAt'] = this.updatedAt.toUtc().toIso8601String();
if (this.albumThumbnailAssetId != null) { if (this.albumThumbnailAssetId != null) {
json[r'albumThumbnailAssetId'] = this.albumThumbnailAssetId; json[r'albumThumbnailAssetId'] = this.albumThumbnailAssetId;
} else { } else {
@ -123,8 +123,8 @@ class AlbumResponseDto {
id: mapValueOfType<String>(json, r'id')!, id: mapValueOfType<String>(json, r'id')!,
ownerId: mapValueOfType<String>(json, r'ownerId')!, ownerId: mapValueOfType<String>(json, r'ownerId')!,
albumName: mapValueOfType<String>(json, r'albumName')!, albumName: mapValueOfType<String>(json, r'albumName')!,
createdAt: mapValueOfType<String>(json, r'createdAt')!, createdAt: mapDateTime(json, r'createdAt', '')!,
updatedAt: mapValueOfType<String>(json, r'updatedAt')!, updatedAt: mapDateTime(json, r'updatedAt', '')!,
albumThumbnailAssetId: mapValueOfType<String>(json, r'albumThumbnailAssetId'), albumThumbnailAssetId: mapValueOfType<String>(json, r'albumThumbnailAssetId'),
shared: mapValueOfType<bool>(json, r'shared')!, shared: mapValueOfType<bool>(json, r'shared')!,
sharedUsers: UserResponseDto.listFromJson(json[r'sharedUsers']), sharedUsers: UserResponseDto.listFromJson(json[r'sharedUsers']),

View File

@ -23,9 +23,9 @@ class APIKeyResponseDto {
String name; String name;
String createdAt; DateTime createdAt;
String updatedAt; DateTime updatedAt;
@override @override
bool operator ==(Object other) => identical(this, other) || other is APIKeyResponseDto && bool operator ==(Object other) => identical(this, other) || other is APIKeyResponseDto &&
@ -49,8 +49,8 @@ class APIKeyResponseDto {
final json = <String, dynamic>{}; final json = <String, dynamic>{};
json[r'id'] = this.id; json[r'id'] = this.id;
json[r'name'] = this.name; json[r'name'] = this.name;
json[r'createdAt'] = this.createdAt; json[r'createdAt'] = this.createdAt.toUtc().toIso8601String();
json[r'updatedAt'] = this.updatedAt; json[r'updatedAt'] = this.updatedAt.toUtc().toIso8601String();
return json; return json;
} }
@ -75,8 +75,8 @@ class APIKeyResponseDto {
return APIKeyResponseDto( return APIKeyResponseDto(
id: mapValueOfType<String>(json, r'id')!, id: mapValueOfType<String>(json, r'id')!,
name: mapValueOfType<String>(json, r'name')!, name: mapValueOfType<String>(json, r'name')!,
createdAt: mapValueOfType<String>(json, r'createdAt')!, createdAt: mapDateTime(json, r'createdAt', '')!,
updatedAt: mapValueOfType<String>(json, r'updatedAt')!, updatedAt: mapDateTime(json, r'updatedAt', '')!,
); );
} }
return null; return null;

View File

@ -29,7 +29,7 @@ class CreateAssetsShareLinkDto {
/// source code must fall back to having a nullable type. /// source code must fall back to having a nullable type.
/// Consider adding a "default:" property in the specification file to hide this note. /// Consider adding a "default:" property in the specification file to hide this note.
/// ///
String? expiresAt; DateTime? expiresAt;
/// ///
/// Please note: This property should have been non-nullable! Since the specification file /// Please note: This property should have been non-nullable! Since the specification file
@ -89,7 +89,7 @@ class CreateAssetsShareLinkDto {
final json = <String, dynamic>{}; final json = <String, dynamic>{};
json[r'assetIds'] = this.assetIds; json[r'assetIds'] = this.assetIds;
if (this.expiresAt != null) { if (this.expiresAt != null) {
json[r'expiresAt'] = this.expiresAt; json[r'expiresAt'] = this.expiresAt!.toUtc().toIso8601String();
} else { } else {
// json[r'expiresAt'] = null; // json[r'expiresAt'] = null;
} }
@ -138,7 +138,7 @@ class CreateAssetsShareLinkDto {
assetIds: json[r'assetIds'] is Iterable assetIds: json[r'assetIds'] is Iterable
? (json[r'assetIds'] as Iterable).cast<String>().toList(growable: false) ? (json[r'assetIds'] as Iterable).cast<String>().toList(growable: false)
: const [], : const [],
expiresAt: mapValueOfType<String>(json, r'expiresAt'), expiresAt: mapDateTime(json, r'expiresAt', ''),
allowUpload: mapValueOfType<bool>(json, r'allowUpload'), allowUpload: mapValueOfType<bool>(json, r'allowUpload'),
allowDownload: mapValueOfType<bool>(json, r'allowDownload'), allowDownload: mapValueOfType<bool>(json, r'allowDownload'),
showExif: mapValueOfType<bool>(json, r'showExif'), showExif: mapValueOfType<bool>(json, r'showExif'),

View File

@ -28,7 +28,7 @@ class EditSharedLinkDto {
/// ///
String? description; String? description;
String? expiresAt; DateTime? expiresAt;
/// ///
/// Please note: This property should have been non-nullable! Since the specification file /// Please note: This property should have been non-nullable! Since the specification file
@ -82,7 +82,7 @@ class EditSharedLinkDto {
// json[r'description'] = null; // json[r'description'] = null;
} }
if (this.expiresAt != null) { if (this.expiresAt != null) {
json[r'expiresAt'] = this.expiresAt; json[r'expiresAt'] = this.expiresAt!.toUtc().toIso8601String();
} else { } else {
// json[r'expiresAt'] = null; // json[r'expiresAt'] = null;
} }
@ -124,7 +124,7 @@ class EditSharedLinkDto {
return EditSharedLinkDto( return EditSharedLinkDto(
description: mapValueOfType<String>(json, r'description'), description: mapValueOfType<String>(json, r'description'),
expiresAt: mapValueOfType<String>(json, r'expiresAt'), expiresAt: mapDateTime(json, r'expiresAt', ''),
allowUpload: mapValueOfType<bool>(json, r'allowUpload'), allowUpload: mapValueOfType<bool>(json, r'allowUpload'),
allowDownload: mapValueOfType<bool>(json, r'allowDownload'), allowDownload: mapValueOfType<bool>(json, r'allowDownload'),
showExif: mapValueOfType<bool>(json, r'showExif'), showExif: mapValueOfType<bool>(json, r'showExif'),

View File

@ -43,9 +43,9 @@ class SharedLinkResponseDto {
String key; String key;
String createdAt; DateTime createdAt;
String? expiresAt; DateTime? expiresAt;
List<AssetResponseDto> assets; List<AssetResponseDto> assets;
@ -108,9 +108,9 @@ class SharedLinkResponseDto {
} }
json[r'userId'] = this.userId; json[r'userId'] = this.userId;
json[r'key'] = this.key; json[r'key'] = this.key;
json[r'createdAt'] = this.createdAt; json[r'createdAt'] = this.createdAt.toUtc().toIso8601String();
if (this.expiresAt != null) { if (this.expiresAt != null) {
json[r'expiresAt'] = this.expiresAt; json[r'expiresAt'] = this.expiresAt!.toUtc().toIso8601String();
} else { } else {
// json[r'expiresAt'] = null; // json[r'expiresAt'] = null;
} }
@ -150,8 +150,8 @@ class SharedLinkResponseDto {
description: mapValueOfType<String>(json, r'description'), description: mapValueOfType<String>(json, r'description'),
userId: mapValueOfType<String>(json, r'userId')!, userId: mapValueOfType<String>(json, r'userId')!,
key: mapValueOfType<String>(json, r'key')!, key: mapValueOfType<String>(json, r'key')!,
createdAt: mapValueOfType<String>(json, r'createdAt')!, createdAt: mapDateTime(json, r'createdAt', '')!,
expiresAt: mapValueOfType<String>(json, r'expiresAt'), expiresAt: mapDateTime(json, r'expiresAt', ''),
assets: AssetResponseDto.listFromJson(json[r'assets']), assets: AssetResponseDto.listFromJson(json[r'assets']),
album: AlbumResponseDto.fromJson(json[r'album']), album: AlbumResponseDto.fromJson(json[r'album']),
allowUpload: mapValueOfType<bool>(json, r'allowUpload')!, allowUpload: mapValueOfType<bool>(json, r'allowUpload')!,

View File

@ -18,12 +18,12 @@ class UserResponseDto {
required this.firstName, required this.firstName,
required this.lastName, required this.lastName,
required this.storageLabel, required this.storageLabel,
required this.createdAt,
required this.profileImagePath, required this.profileImagePath,
required this.shouldChangePassword, required this.shouldChangePassword,
required this.isAdmin, required this.isAdmin,
this.deletedAt, required this.createdAt,
this.updatedAt, required this.deletedAt,
required this.updatedAt,
required this.oauthId, required this.oauthId,
}); });
@ -37,29 +37,17 @@ class UserResponseDto {
String? storageLabel; String? storageLabel;
String createdAt;
String profileImagePath; String profileImagePath;
bool shouldChangePassword; bool shouldChangePassword;
bool isAdmin; bool isAdmin;
/// DateTime createdAt;
/// 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; DateTime? deletedAt;
/// DateTime updatedAt;
/// 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.
///
String? updatedAt;
String oauthId; String oauthId;
@ -70,10 +58,10 @@ class UserResponseDto {
other.firstName == firstName && other.firstName == firstName &&
other.lastName == lastName && other.lastName == lastName &&
other.storageLabel == storageLabel && other.storageLabel == storageLabel &&
other.createdAt == createdAt &&
other.profileImagePath == profileImagePath && other.profileImagePath == profileImagePath &&
other.shouldChangePassword == shouldChangePassword && other.shouldChangePassword == shouldChangePassword &&
other.isAdmin == isAdmin && other.isAdmin == isAdmin &&
other.createdAt == createdAt &&
other.deletedAt == deletedAt && other.deletedAt == deletedAt &&
other.updatedAt == updatedAt && other.updatedAt == updatedAt &&
other.oauthId == oauthId; other.oauthId == oauthId;
@ -86,16 +74,16 @@ class UserResponseDto {
(firstName.hashCode) + (firstName.hashCode) +
(lastName.hashCode) + (lastName.hashCode) +
(storageLabel == null ? 0 : storageLabel!.hashCode) + (storageLabel == null ? 0 : storageLabel!.hashCode) +
(createdAt.hashCode) +
(profileImagePath.hashCode) + (profileImagePath.hashCode) +
(shouldChangePassword.hashCode) + (shouldChangePassword.hashCode) +
(isAdmin.hashCode) + (isAdmin.hashCode) +
(createdAt.hashCode) +
(deletedAt == null ? 0 : deletedAt!.hashCode) + (deletedAt == null ? 0 : deletedAt!.hashCode) +
(updatedAt == null ? 0 : updatedAt!.hashCode) + (updatedAt.hashCode) +
(oauthId.hashCode); (oauthId.hashCode);
@override @override
String toString() => 'UserResponseDto[id=$id, email=$email, firstName=$firstName, lastName=$lastName, storageLabel=$storageLabel, createdAt=$createdAt, profileImagePath=$profileImagePath, shouldChangePassword=$shouldChangePassword, isAdmin=$isAdmin, deletedAt=$deletedAt, updatedAt=$updatedAt, oauthId=$oauthId]'; String toString() => 'UserResponseDto[id=$id, email=$email, firstName=$firstName, lastName=$lastName, storageLabel=$storageLabel, profileImagePath=$profileImagePath, shouldChangePassword=$shouldChangePassword, isAdmin=$isAdmin, createdAt=$createdAt, deletedAt=$deletedAt, updatedAt=$updatedAt, oauthId=$oauthId]';
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final json = <String, dynamic>{}; final json = <String, dynamic>{};
@ -108,20 +96,16 @@ class UserResponseDto {
} else { } else {
// json[r'storageLabel'] = null; // json[r'storageLabel'] = null;
} }
json[r'createdAt'] = this.createdAt;
json[r'profileImagePath'] = this.profileImagePath; json[r'profileImagePath'] = this.profileImagePath;
json[r'shouldChangePassword'] = this.shouldChangePassword; json[r'shouldChangePassword'] = this.shouldChangePassword;
json[r'isAdmin'] = this.isAdmin; json[r'isAdmin'] = this.isAdmin;
json[r'createdAt'] = this.createdAt.toUtc().toIso8601String();
if (this.deletedAt != null) { if (this.deletedAt != null) {
json[r'deletedAt'] = this.deletedAt!.toUtc().toIso8601String(); json[r'deletedAt'] = this.deletedAt!.toUtc().toIso8601String();
} else { } else {
// json[r'deletedAt'] = null; // json[r'deletedAt'] = null;
} }
if (this.updatedAt != null) { json[r'updatedAt'] = this.updatedAt.toUtc().toIso8601String();
json[r'updatedAt'] = this.updatedAt;
} else {
// json[r'updatedAt'] = null;
}
json[r'oauthId'] = this.oauthId; json[r'oauthId'] = this.oauthId;
return json; return json;
} }
@ -150,12 +134,12 @@ class UserResponseDto {
firstName: mapValueOfType<String>(json, r'firstName')!, firstName: mapValueOfType<String>(json, r'firstName')!,
lastName: mapValueOfType<String>(json, r'lastName')!, lastName: mapValueOfType<String>(json, r'lastName')!,
storageLabel: mapValueOfType<String>(json, r'storageLabel'), storageLabel: mapValueOfType<String>(json, r'storageLabel'),
createdAt: mapValueOfType<String>(json, r'createdAt')!,
profileImagePath: mapValueOfType<String>(json, r'profileImagePath')!, profileImagePath: mapValueOfType<String>(json, r'profileImagePath')!,
shouldChangePassword: mapValueOfType<bool>(json, r'shouldChangePassword')!, shouldChangePassword: mapValueOfType<bool>(json, r'shouldChangePassword')!,
isAdmin: mapValueOfType<bool>(json, r'isAdmin')!, isAdmin: mapValueOfType<bool>(json, r'isAdmin')!,
createdAt: mapDateTime(json, r'createdAt', '')!,
deletedAt: mapDateTime(json, r'deletedAt', ''), deletedAt: mapDateTime(json, r'deletedAt', ''),
updatedAt: mapValueOfType<String>(json, r'updatedAt'), updatedAt: mapDateTime(json, r'updatedAt', '')!,
oauthId: mapValueOfType<String>(json, r'oauthId')!, oauthId: mapValueOfType<String>(json, r'oauthId')!,
); );
} }
@ -209,10 +193,12 @@ class UserResponseDto {
'firstName', 'firstName',
'lastName', 'lastName',
'storageLabel', 'storageLabel',
'createdAt',
'profileImagePath', 'profileImagePath',
'shouldChangePassword', 'shouldChangePassword',
'isAdmin', 'isAdmin',
'createdAt',
'deletedAt',
'updatedAt',
'oauthId', 'oauthId',
}; };
} }

View File

@ -36,7 +36,7 @@ void main() {
// TODO // TODO
}); });
// String createdAt // DateTime createdAt
test('to test the property `createdAt`', () async { test('to test the property `createdAt`', () async {
// TODO // TODO
}); });

View File

@ -36,12 +36,12 @@ void main() {
// TODO // TODO
}); });
// String createdAt // DateTime createdAt
test('to test the property `createdAt`', () async { test('to test the property `createdAt`', () async {
// TODO // TODO
}); });
// String updatedAt // DateTime updatedAt
test('to test the property `updatedAt`', () async { test('to test the property `updatedAt`', () async {
// TODO // TODO
}); });

View File

@ -26,12 +26,12 @@ void main() {
// TODO // TODO
}); });
// String createdAt // DateTime createdAt
test('to test the property `createdAt`', () async { test('to test the property `createdAt`', () async {
// TODO // TODO
}); });
// String updatedAt // DateTime updatedAt
test('to test the property `updatedAt`', () async { test('to test the property `updatedAt`', () async {
// TODO // TODO
}); });

View File

@ -21,7 +21,7 @@ void main() {
// TODO // TODO
}); });
// String expiresAt // DateTime expiresAt
test('to test the property `expiresAt`', () async { test('to test the property `expiresAt`', () async {
// TODO // TODO
}); });

View File

@ -21,7 +21,7 @@ void main() {
// TODO // TODO
}); });
// String expiresAt // DateTime expiresAt
test('to test the property `expiresAt`', () async { test('to test the property `expiresAt`', () async {
// TODO // TODO
}); });

View File

@ -41,12 +41,12 @@ void main() {
// TODO // TODO
}); });
// String createdAt // DateTime createdAt
test('to test the property `createdAt`', () async { test('to test the property `createdAt`', () async {
// TODO // TODO
}); });
// String expiresAt // DateTime expiresAt
test('to test the property `expiresAt`', () async { test('to test the property `expiresAt`', () async {
// TODO // TODO
}); });

View File

@ -41,11 +41,6 @@ void main() {
// TODO // TODO
}); });
// String createdAt
test('to test the property `createdAt`', () async {
// TODO
});
// String profileImagePath // String profileImagePath
test('to test the property `profileImagePath`', () async { test('to test the property `profileImagePath`', () async {
// TODO // TODO
@ -61,12 +56,17 @@ void main() {
// TODO // TODO
}); });
// DateTime createdAt
test('to test the property `createdAt`', () async {
// TODO
});
// DateTime deletedAt // DateTime deletedAt
test('to test the property `deletedAt`', () async { test('to test the property `deletedAt`', () async {
// TODO // TODO
}); });
// String updatedAt // DateTime updatedAt
test('to test the property `updatedAt`', () async { test('to test the property `updatedAt`', () async {
// TODO // TODO
}); });

View File

@ -61,7 +61,7 @@ export class AlbumRepository implements IAlbumRepository {
async addSharedUsers(album: AlbumEntity, addUsersDto: AddUsersDto): Promise<AlbumEntity> { async addSharedUsers(album: AlbumEntity, addUsersDto: AddUsersDto): Promise<AlbumEntity> {
album.sharedUsers.push(...addUsersDto.sharedUserIds.map((id) => ({ id } as UserEntity))); album.sharedUsers.push(...addUsersDto.sharedUserIds.map((id) => ({ id } as UserEntity)));
album.updatedAt = new Date().toISOString(); album.updatedAt = new Date();
await this.albumRepository.save(album); await this.albumRepository.save(album);
@ -71,7 +71,7 @@ export class AlbumRepository implements IAlbumRepository {
async removeUser(album: AlbumEntity, userId: string): Promise<void> { async removeUser(album: AlbumEntity, userId: string): Promise<void> {
album.sharedUsers = album.sharedUsers.filter((user) => user.id !== userId); album.sharedUsers = album.sharedUsers.filter((user) => user.id !== userId);
album.updatedAt = new Date().toISOString(); album.updatedAt = new Date();
await this.albumRepository.save(album); await this.albumRepository.save(album);
} }
@ -84,7 +84,7 @@ export class AlbumRepository implements IAlbumRepository {
const numRemovedAssets = assetCount - album.assets.length; const numRemovedAssets = assetCount - album.assets.length;
if (numRemovedAssets > 0) { if (numRemovedAssets > 0) {
album.updatedAt = new Date().toISOString(); album.updatedAt = new Date();
} }
await this.albumRepository.save(album, {}); await this.albumRepository.save(album, {});
@ -111,7 +111,7 @@ export class AlbumRepository implements IAlbumRepository {
const successfullyAdded = addAssetsDto.assetIds.length - alreadyExisting.length; const successfullyAdded = addAssetsDto.assetIds.length - alreadyExisting.length;
if (successfullyAdded > 0) { if (successfullyAdded > 0) {
album.updatedAt = new Date().toISOString(); album.updatedAt = new Date();
} }
await this.albumRepository.save(album); await this.albumRepository.save(album);

View File

@ -32,8 +32,9 @@ describe('Album service', () => {
...authUser, ...authUser,
firstName: 'auth', firstName: 'auth',
lastName: 'user', lastName: 'user',
createdAt: 'date', createdAt: new Date('2022-06-19T23:41:36.910Z'),
updatedAt: 'date', deletedAt: null,
updatedAt: new Date('2022-06-19T23:41:36.910Z'),
profileImagePath: '', profileImagePath: '',
shouldChangePassword: false, shouldChangePassword: false,
oauthId: '', oauthId: '',
@ -52,8 +53,8 @@ describe('Album service', () => {
albumEntity.owner = albumOwner; albumEntity.owner = albumOwner;
albumEntity.id = albumId; albumEntity.id = albumId;
albumEntity.albumName = 'name'; albumEntity.albumName = 'name';
albumEntity.createdAt = 'date'; albumEntity.createdAt = new Date('2022-06-19T23:41:36.910Z');
albumEntity.updatedAt = 'date'; albumEntity.updatedAt = new Date('2022-06-19T23:41:36.910Z');
albumEntity.sharedUsers = []; albumEntity.sharedUsers = [];
albumEntity.assets = []; albumEntity.assets = [];
albumEntity.albumThumbnailAssetId = null; albumEntity.albumThumbnailAssetId = null;
@ -67,7 +68,7 @@ describe('Album service', () => {
albumEntity.owner = albumOwner; albumEntity.owner = albumOwner;
albumEntity.id = albumId; albumEntity.id = albumId;
albumEntity.albumName = 'name'; albumEntity.albumName = 'name';
albumEntity.createdAt = 'date'; albumEntity.createdAt = new Date('2022-06-19T23:41:36.910Z');
albumEntity.assets = []; albumEntity.assets = [];
albumEntity.albumThumbnailAssetId = null; albumEntity.albumThumbnailAssetId = null;
albumEntity.sharedUsers = [ albumEntity.sharedUsers = [
@ -86,7 +87,7 @@ describe('Album service', () => {
albumEntity.owner = albumOwner; albumEntity.owner = albumOwner;
albumEntity.id = albumId; albumEntity.id = albumId;
albumEntity.albumName = 'name'; albumEntity.albumName = 'name';
albumEntity.createdAt = 'date'; albumEntity.createdAt = new Date('2022-06-19T23:41:36.910Z');
albumEntity.assets = []; albumEntity.assets = [];
albumEntity.albumThumbnailAssetId = null; albumEntity.albumThumbnailAssetId = null;
albumEntity.sharedUsers = [ albumEntity.sharedUsers = [
@ -109,7 +110,7 @@ describe('Album service', () => {
albumEntity.ownerId = '5555'; albumEntity.ownerId = '5555';
albumEntity.id = albumId; albumEntity.id = albumId;
albumEntity.albumName = 'name'; albumEntity.albumName = 'name';
albumEntity.createdAt = 'date'; albumEntity.createdAt = new Date('2022-06-19T23:41:36.910Z');
albumEntity.sharedUsers = []; albumEntity.sharedUsers = [];
albumEntity.assets = []; albumEntity.assets = [];
albumEntity.albumThumbnailAssetId = null; albumEntity.albumThumbnailAssetId = null;
@ -158,8 +159,8 @@ describe('Album service', () => {
owner: mapUser(albumOwner), owner: mapUser(albumOwner),
id: albumId, id: albumId,
albumName: 'name', albumName: 'name',
createdAt: 'date', createdAt: new Date('2022-06-19T23:41:36.910Z'),
updatedAt: 'date', updatedAt: new Date('2022-06-19T23:41:36.910Z'),
sharedUsers: [], sharedUsers: [],
assets: [], assets: [],
albumThumbnailAssetId: null, albumThumbnailAssetId: null,

View File

@ -1,15 +1,17 @@
import { ApiProperty } from '@nestjs/swagger'; import { ApiProperty } from '@nestjs/swagger';
import { ValidateUUID } from 'apps/immich/src/decorators/validate-uuid.decorator'; import { ValidateUUID } from 'apps/immich/src/decorators/validate-uuid.decorator';
import { IsBoolean, IsISO8601, IsOptional, IsString } from 'class-validator'; import { Type } from 'class-transformer';
import { IsBoolean, IsDate, IsOptional, IsString } from 'class-validator';
export class CreateAlbumShareLinkDto { export class CreateAlbumShareLinkDto {
@ValidateUUID() @ValidateUUID()
albumId!: string; albumId!: string;
@IsISO8601()
@IsOptional() @IsOptional()
@ApiProperty({ format: 'date-time' }) @IsDate()
expiresAt?: string; @Type(() => Date)
@ApiProperty()
expiresAt?: Date;
@IsBoolean() @IsBoolean()
@IsOptional() @IsOptional()

View File

@ -1,5 +1,6 @@
import { ApiProperty } from '@nestjs/swagger'; import { ApiProperty } from '@nestjs/swagger';
import { IsArray, IsBoolean, IsNotEmpty, IsOptional, IsString } from 'class-validator'; import { Type } from 'class-transformer';
import { IsArray, IsBoolean, IsDate, IsNotEmpty, IsOptional, IsString } from 'class-validator';
export class CreateAssetsShareLinkDto { export class CreateAssetsShareLinkDto {
@IsArray() @IsArray()
@ -17,9 +18,10 @@ export class CreateAssetsShareLinkDto {
}) })
assetIds!: string[]; assetIds!: string[];
@IsString() @IsDate()
@Type(() => Date)
@IsOptional() @IsOptional()
expiresAt?: string; expiresAt?: Date;
@IsBoolean() @IsBoolean()
@IsOptional() @IsOptional()

View File

@ -21,9 +21,9 @@ describe('TagService', () => {
email: 'testuser@email.com', email: 'testuser@email.com',
profileImagePath: '', profileImagePath: '',
shouldChangePassword: true, shouldChangePassword: true,
createdAt: '2022-12-02T19:29:23.603Z', createdAt: new Date('2022-12-02T19:29:23.603Z'),
deletedAt: undefined, deletedAt: null,
updatedAt: '2022-12-02T19:29:23.603Z', updatedAt: new Date('2022-12-02T19:29:23.603Z'),
tags: [], tags: [],
assets: [], assets: [],
oauthId: 'oauth-id-1', oauthId: 'oauth-id-1',

View File

@ -4196,9 +4196,6 @@
"type": "string", "type": "string",
"nullable": true "nullable": true
}, },
"createdAt": {
"type": "string"
},
"profileImagePath": { "profileImagePath": {
"type": "string" "type": "string"
}, },
@ -4208,11 +4205,17 @@
"isAdmin": { "isAdmin": {
"type": "boolean" "type": "boolean"
}, },
"deletedAt": { "createdAt": {
"format": "date-time", "format": "date-time",
"type": "string" "type": "string"
}, },
"deletedAt": {
"format": "date-time",
"type": "string",
"nullable": true
},
"updatedAt": { "updatedAt": {
"format": "date-time",
"type": "string" "type": "string"
}, },
"oauthId": { "oauthId": {
@ -4225,10 +4228,12 @@
"firstName", "firstName",
"lastName", "lastName",
"storageLabel", "storageLabel",
"createdAt",
"profileImagePath", "profileImagePath",
"shouldChangePassword", "shouldChangePassword",
"isAdmin", "isAdmin",
"createdAt",
"deletedAt",
"updatedAt",
"oauthId" "oauthId"
] ]
}, },
@ -4536,9 +4541,11 @@
"type": "string" "type": "string"
}, },
"createdAt": { "createdAt": {
"format": "date-time",
"type": "string" "type": "string"
}, },
"updatedAt": { "updatedAt": {
"format": "date-time",
"type": "string" "type": "string"
}, },
"albumThumbnailAssetId": { "albumThumbnailAssetId": {
@ -4633,9 +4640,11 @@
"type": "string" "type": "string"
}, },
"createdAt": { "createdAt": {
"format": "date-time",
"type": "string" "type": "string"
}, },
"updatedAt": { "updatedAt": {
"format": "date-time",
"type": "string" "type": "string"
} }
}, },
@ -4800,6 +4809,7 @@
"type": "string" "type": "string"
}, },
"createdAt": { "createdAt": {
"format": "date-time",
"type": "string" "type": "string"
} }
}, },
@ -5396,9 +5406,11 @@
"type": "string" "type": "string"
}, },
"createdAt": { "createdAt": {
"format": "date-time",
"type": "string" "type": "string"
}, },
"expiresAt": { "expiresAt": {
"format": "date-time",
"type": "string", "type": "string",
"nullable": true "nullable": true
}, },
@ -5441,6 +5453,7 @@
"type": "string" "type": "string"
}, },
"expiresAt": { "expiresAt": {
"format": "date-time",
"type": "string", "type": "string",
"nullable": true "nullable": true
}, },
@ -6255,6 +6268,7 @@
} }
}, },
"expiresAt": { "expiresAt": {
"format": "date-time",
"type": "string" "type": "string"
}, },
"allowUpload": { "allowUpload": {
@ -6393,8 +6407,8 @@
"format": "uuid" "format": "uuid"
}, },
"expiresAt": { "expiresAt": {
"type": "string", "format": "date-time",
"format": "date-time" "type": "string"
}, },
"allowUpload": { "allowUpload": {
"type": "boolean" "type": "boolean"

View File

@ -128,7 +128,6 @@ describe(AlbumService.name, () => {
createdAt: expect.anything(), createdAt: expect.anything(),
id: 'album-1', id: 'album-1',
owner: { owner: {
createdAt: '2021-01-01',
email: 'admin@test.com', email: 'admin@test.com',
firstName: 'admin_first_name', firstName: 'admin_first_name',
id: 'admin_id', id: 'admin_id',
@ -138,7 +137,9 @@ describe(AlbumService.name, () => {
profileImagePath: '', profileImagePath: '',
shouldChangePassword: false, shouldChangePassword: false,
storageLabel: 'admin', storageLabel: 'admin',
updatedAt: '2021-01-01', createdAt: new Date('2021-01-01'),
deletedAt: null,
updatedAt: new Date('2021-01-01'),
}, },
ownerId: 'admin_id', ownerId: 'admin_id',
shared: false, shared: false,

View File

@ -7,8 +7,8 @@ export class AlbumResponseDto {
id!: string; id!: string;
ownerId!: string; ownerId!: string;
albumName!: string; albumName!: string;
createdAt!: string; createdAt!: Date;
updatedAt!: string; updatedAt!: Date;
albumThumbnailAssetId!: string | null; albumThumbnailAssetId!: string | null;
shared!: boolean; shared!: boolean;
sharedUsers!: UserResponseDto[]; sharedUsers!: UserResponseDto[];

View File

@ -8,8 +8,8 @@ export class APIKeyCreateResponseDto {
export class APIKeyResponseDto { export class APIKeyResponseDto {
id!: string; id!: string;
name!: string; name!: string;
createdAt!: string; createdAt!: Date;
updatedAt!: string; updatedAt!: Date;
} }
export function mapKey(entity: APIKeyEntity): APIKeyResponseDto { export function mapKey(entity: APIKeyEntity): APIKeyResponseDto {

View File

@ -231,10 +231,10 @@ describe('AuthService', () => {
it('should sign up the admin', async () => { it('should sign up the admin', async () => {
userMock.getAdmin.mockResolvedValue(null); userMock.getAdmin.mockResolvedValue(null);
userMock.create.mockResolvedValue({ ...dto, id: 'admin', createdAt: 'today' } as UserEntity); userMock.create.mockResolvedValue({ ...dto, id: 'admin', createdAt: new Date('2021-01-01') } as UserEntity);
await expect(sut.adminSignUp(dto)).resolves.toEqual({ await expect(sut.adminSignUp(dto)).resolves.toEqual({
id: 'admin', id: 'admin',
createdAt: 'today', createdAt: new Date('2021-01-01'),
email: 'test@immich.com', email: 'test@immich.com',
firstName: 'immich', firstName: 'immich',
lastName: 'admin', lastName: 'admin',

View File

@ -5,7 +5,7 @@ export class AdminSignupResponseDto {
email!: string; email!: string;
firstName!: string; firstName!: string;
lastName!: string; lastName!: string;
createdAt!: string; createdAt!: Date;
} }
export function mapAdminSignupResponse(entity: UserEntity): AdminSignupResponseDto { export function mapAdminSignupResponse(entity: UserEntity): AdminSignupResponseDto {

View File

@ -6,8 +6,6 @@ import { PartnerService } from './partner.service';
const responseDto = { const responseDto = {
admin: { admin: {
createdAt: '2021-01-01',
deletedAt: undefined,
email: 'admin@test.com', email: 'admin@test.com',
firstName: 'admin_first_name', firstName: 'admin_first_name',
id: 'admin_id', id: 'admin_id',
@ -16,12 +14,12 @@ const responseDto = {
oauthId: '', oauthId: '',
profileImagePath: '', profileImagePath: '',
shouldChangePassword: false, shouldChangePassword: false,
updatedAt: '2021-01-01',
storageLabel: 'admin', storageLabel: 'admin',
createdAt: new Date('2021-01-01'),
deletedAt: null,
updatedAt: new Date('2021-01-01'),
}, },
user1: { user1: {
createdAt: '2021-01-01',
deletedAt: undefined,
email: 'immich@test.com', email: 'immich@test.com',
firstName: 'immich_first_name', firstName: 'immich_first_name',
id: 'user-id', id: 'user-id',
@ -30,8 +28,10 @@ const responseDto = {
oauthId: '', oauthId: '',
profileImagePath: '', profileImagePath: '',
shouldChangePassword: false, shouldChangePassword: false,
updatedAt: '2021-01-01',
storageLabel: null, storageLabel: null,
createdAt: new Date('2021-01-01'),
deletedAt: null,
updatedAt: new Date('2021-01-01'),
}, },
}; };

View File

@ -2,7 +2,7 @@ import { AlbumEntity, AssetEntity, SharedLinkType } from '@app/infra/entities';
export class CreateSharedLinkDto { export class CreateSharedLinkDto {
description?: string; description?: string;
expiresAt?: string; expiresAt?: Date;
type!: SharedLinkType; type!: SharedLinkType;
assets!: AssetEntity[]; assets!: AssetEntity[];
album?: AlbumEntity; album?: AlbumEntity;

View File

@ -5,7 +5,7 @@ export class EditSharedLinkDto {
description?: string; description?: string;
@IsOptional() @IsOptional()
expiresAt?: string | null; expiresAt?: Date | null;
@IsOptional() @IsOptional()
allowUpload?: boolean; allowUpload?: boolean;

View File

@ -12,8 +12,8 @@ export class SharedLinkResponseDto {
@ApiProperty({ enumName: 'SharedLinkType', enum: SharedLinkType }) @ApiProperty({ enumName: 'SharedLinkType', enum: SharedLinkType })
type!: SharedLinkType; type!: SharedLinkType;
createdAt!: string; createdAt!: Date;
expiresAt!: string | null; expiresAt!: Date | null;
assets!: AssetResponseDto[]; assets!: AssetResponseDto[];
album?: AlbumResponseDto; album?: AlbumResponseDto;
allowUpload!: boolean; allowUpload!: boolean;

View File

@ -23,7 +23,7 @@ export class ShareCore {
key: Buffer.from(this.cryptoRepository.randomBytes(50)), key: Buffer.from(this.cryptoRepository.randomBytes(50)),
description: dto.description, description: dto.description,
userId, userId,
createdAt: new Date().toISOString(), createdAt: new Date(),
expiresAt: dto.expiresAt ?? null, expiresAt: dto.expiresAt ?? null,
type: dto.type, type: dto.type,
assets: dto.assets, assets: dto.assets,

View File

@ -6,12 +6,12 @@ export class UserResponseDto {
firstName!: string; firstName!: string;
lastName!: string; lastName!: string;
storageLabel!: string | null; storageLabel!: string | null;
createdAt!: string;
profileImagePath!: string; profileImagePath!: string;
shouldChangePassword!: boolean; shouldChangePassword!: boolean;
isAdmin!: boolean; isAdmin!: boolean;
deletedAt?: Date; createdAt!: Date;
updatedAt?: string; deletedAt!: Date | null;
updatedAt!: Date;
oauthId!: string; oauthId!: string;
} }
@ -22,10 +22,10 @@ export function mapUser(entity: UserEntity): UserResponseDto {
firstName: entity.firstName, firstName: entity.firstName,
lastName: entity.lastName, lastName: entity.lastName,
storageLabel: entity.storageLabel, storageLabel: entity.storageLabel,
createdAt: entity.createdAt,
profileImagePath: entity.profileImagePath, profileImagePath: entity.profileImagePath,
shouldChangePassword: entity.shouldChangePassword, shouldChangePassword: entity.shouldChangePassword,
isAdmin: entity.isAdmin, isAdmin: entity.isAdmin,
createdAt: entity.createdAt,
deletedAt: entity.deletedAt, deletedAt: entity.deletedAt,
updatedAt: entity.updatedAt, updatedAt: entity.updatedAt,
oauthId: entity.oauthId, oauthId: entity.oauthId,

View File

@ -47,8 +47,9 @@ const adminUser: UserEntity = Object.freeze({
oauthId: '', oauthId: '',
shouldChangePassword: false, shouldChangePassword: false,
profileImagePath: '', profileImagePath: '',
createdAt: '2021-01-01', createdAt: new Date('2021-01-01'),
updatedAt: '2021-01-01', deletedAt: null,
updatedAt: new Date('2021-01-01'),
tags: [], tags: [],
assets: [], assets: [],
storageLabel: 'admin', storageLabel: 'admin',
@ -64,8 +65,9 @@ const immichUser: UserEntity = Object.freeze({
oauthId: '', oauthId: '',
shouldChangePassword: false, shouldChangePassword: false,
profileImagePath: '', profileImagePath: '',
createdAt: '2021-01-01', createdAt: new Date('2021-01-01'),
updatedAt: '2021-01-01', deletedAt: null,
updatedAt: new Date('2021-01-01'),
tags: [], tags: [],
assets: [], assets: [],
storageLabel: null, storageLabel: null,
@ -81,8 +83,9 @@ const updatedImmichUser: UserEntity = Object.freeze({
oauthId: '', oauthId: '',
shouldChangePassword: true, shouldChangePassword: true,
profileImagePath: '', profileImagePath: '',
createdAt: '2021-01-01', createdAt: new Date('2021-01-01'),
updatedAt: '2021-01-01', deletedAt: null,
updatedAt: new Date('2021-01-01'),
tags: [], tags: [],
assets: [], assets: [],
storageLabel: null, storageLabel: null,
@ -91,15 +94,15 @@ const updatedImmichUser: UserEntity = Object.freeze({
const adminUserResponse = Object.freeze({ const adminUserResponse = Object.freeze({
id: adminUserAuth.id, id: adminUserAuth.id,
email: 'admin@test.com', email: 'admin@test.com',
deletedAt: undefined,
firstName: 'admin_first_name', firstName: 'admin_first_name',
lastName: 'admin_last_name', lastName: 'admin_last_name',
isAdmin: true, isAdmin: true,
oauthId: '', oauthId: '',
shouldChangePassword: false, shouldChangePassword: false,
profileImagePath: '', profileImagePath: '',
createdAt: '2021-01-01', createdAt: new Date('2021-01-01'),
updatedAt: '2021-01-01', deletedAt: null,
updatedAt: new Date('2021-01-01'),
storageLabel: 'admin', storageLabel: 'admin',
}); });
@ -140,15 +143,15 @@ describe(UserService.name, () => {
{ {
id: adminUserAuth.id, id: adminUserAuth.id,
email: 'admin@test.com', email: 'admin@test.com',
deletedAt: undefined,
firstName: 'admin_first_name', firstName: 'admin_first_name',
lastName: 'admin_last_name', lastName: 'admin_last_name',
isAdmin: true, isAdmin: true,
oauthId: '', oauthId: '',
shouldChangePassword: false, shouldChangePassword: false,
profileImagePath: '', profileImagePath: '',
createdAt: '2021-01-01', createdAt: new Date('2021-01-01'),
updatedAt: '2021-01-01', deletedAt: null,
updatedAt: new Date('2021-01-01'),
storageLabel: 'admin', storageLabel: 'admin',
}, },
]); ]);

View File

@ -85,8 +85,9 @@ export const userEntityStub = {
oauthId: '', oauthId: '',
shouldChangePassword: false, shouldChangePassword: false,
profileImagePath: '', profileImagePath: '',
createdAt: '2021-01-01', createdAt: new Date('2021-01-01'),
updatedAt: '2021-01-01', deletedAt: null,
updatedAt: new Date('2021-01-01'),
tags: [], tags: [],
assets: [], assets: [],
}), }),
@ -99,8 +100,9 @@ export const userEntityStub = {
oauthId: '', oauthId: '',
shouldChangePassword: false, shouldChangePassword: false,
profileImagePath: '', profileImagePath: '',
createdAt: '2021-01-01', createdAt: new Date('2021-01-01'),
updatedAt: '2021-01-01', deletedAt: null,
updatedAt: new Date('2021-01-01'),
tags: [], tags: [],
assets: [], assets: [],
}), }),
@ -113,8 +115,9 @@ export const userEntityStub = {
oauthId: '', oauthId: '',
shouldChangePassword: false, shouldChangePassword: false,
profileImagePath: '', profileImagePath: '',
createdAt: '2021-01-01', createdAt: new Date('2021-01-01'),
updatedAt: '2021-01-01', deletedAt: null,
updatedAt: new Date('2021-01-01'),
tags: [], tags: [],
assets: [], assets: [],
}), }),
@ -317,8 +320,8 @@ export const albumStub = {
assets: [], assets: [],
albumThumbnailAsset: null, albumThumbnailAsset: null,
albumThumbnailAssetId: null, albumThumbnailAssetId: null,
createdAt: new Date().toISOString(), createdAt: new Date(),
updatedAt: new Date().toISOString(), updatedAt: new Date(),
sharedLinks: [], sharedLinks: [],
sharedUsers: [], sharedUsers: [],
}), }),
@ -330,8 +333,8 @@ export const albumStub = {
assets: [], assets: [],
albumThumbnailAsset: null, albumThumbnailAsset: null,
albumThumbnailAssetId: null, albumThumbnailAssetId: null,
createdAt: new Date().toISOString(), createdAt: new Date(),
updatedAt: new Date().toISOString(), updatedAt: new Date(),
sharedLinks: [], sharedLinks: [],
sharedUsers: [userEntityStub.user1], sharedUsers: [userEntityStub.user1],
}), }),
@ -343,8 +346,8 @@ export const albumStub = {
assets: [], assets: [],
albumThumbnailAsset: null, albumThumbnailAsset: null,
albumThumbnailAssetId: null, albumThumbnailAssetId: null,
createdAt: new Date().toISOString(), createdAt: new Date(),
updatedAt: new Date().toISOString(), updatedAt: new Date(),
sharedLinks: [], sharedLinks: [],
sharedUsers: [userEntityStub.admin], sharedUsers: [userEntityStub.admin],
}), }),
@ -356,8 +359,8 @@ export const albumStub = {
assets: [assetEntityStub.image], assets: [assetEntityStub.image],
albumThumbnailAsset: null, albumThumbnailAsset: null,
albumThumbnailAssetId: null, albumThumbnailAssetId: null,
createdAt: new Date().toISOString(), createdAt: new Date(),
updatedAt: new Date().toISOString(), updatedAt: new Date(),
sharedLinks: [], sharedLinks: [],
sharedUsers: [], sharedUsers: [],
}), }),
@ -369,8 +372,8 @@ export const albumStub = {
assets: [], assets: [],
albumThumbnailAsset: assetEntityStub.image, albumThumbnailAsset: assetEntityStub.image,
albumThumbnailAssetId: assetEntityStub.image.id, albumThumbnailAssetId: assetEntityStub.image.id,
createdAt: new Date().toISOString(), createdAt: new Date(),
updatedAt: new Date().toISOString(), updatedAt: new Date(),
sharedLinks: [], sharedLinks: [],
sharedUsers: [], sharedUsers: [],
}), }),
@ -382,8 +385,8 @@ export const albumStub = {
assets: [], assets: [],
albumThumbnailAsset: null, albumThumbnailAsset: null,
albumThumbnailAssetId: null, albumThumbnailAssetId: null,
createdAt: new Date().toISOString(), createdAt: new Date(),
updatedAt: new Date().toISOString(), updatedAt: new Date(),
sharedLinks: [], sharedLinks: [],
sharedUsers: [], sharedUsers: [],
}), }),
@ -395,8 +398,8 @@ export const albumStub = {
assets: [assetEntityStub.image], assets: [assetEntityStub.image],
albumThumbnailAsset: assetEntityStub.livePhotoMotionAsset, albumThumbnailAsset: assetEntityStub.livePhotoMotionAsset,
albumThumbnailAssetId: assetEntityStub.livePhotoMotionAsset.id, albumThumbnailAssetId: assetEntityStub.livePhotoMotionAsset.id,
createdAt: new Date().toISOString(), createdAt: new Date(),
updatedAt: new Date().toISOString(), updatedAt: new Date(),
sharedLinks: [], sharedLinks: [],
sharedUsers: [], sharedUsers: [],
}), }),
@ -408,8 +411,8 @@ export const albumStub = {
assets: [assetEntityStub.image], assets: [assetEntityStub.image],
albumThumbnailAsset: assetEntityStub.image, albumThumbnailAsset: assetEntityStub.image,
albumThumbnailAssetId: assetEntityStub.image.id, albumThumbnailAssetId: assetEntityStub.image.id,
createdAt: new Date().toISOString(), createdAt: new Date(),
updatedAt: new Date().toISOString(), updatedAt: new Date(),
sharedLinks: [], sharedLinks: [],
sharedUsers: [], sharedUsers: [],
}), }),
@ -468,8 +471,8 @@ const assetResponse: AssetResponseDto = {
const albumResponse: AlbumResponseDto = { const albumResponse: AlbumResponseDto = {
albumName: 'Test Album', albumName: 'Test Album',
albumThumbnailAssetId: null, albumThumbnailAssetId: null,
createdAt: today.toISOString(), createdAt: today,
updatedAt: today.toISOString(), updatedAt: today,
id: 'album-123', id: 'album-123',
ownerId: 'admin_id', ownerId: 'admin_id',
owner: mapUser(userEntityStub.admin), owner: mapUser(userEntityStub.admin),
@ -645,8 +648,8 @@ export const sharedLinkStub = {
user: userEntityStub.admin, user: userEntityStub.admin,
key: Buffer.from('secret-key', 'utf8'), key: Buffer.from('secret-key', 'utf8'),
type: SharedLinkType.ALBUM, type: SharedLinkType.ALBUM,
createdAt: today.toISOString(), createdAt: today,
expiresAt: tomorrow.toISOString(), expiresAt: tomorrow,
allowUpload: true, allowUpload: true,
allowDownload: true, allowDownload: true,
showExif: true, showExif: true,
@ -659,8 +662,8 @@ export const sharedLinkStub = {
user: userEntityStub.admin, user: userEntityStub.admin,
key: Buffer.from('secret-key', 'utf8'), key: Buffer.from('secret-key', 'utf8'),
type: SharedLinkType.ALBUM, type: SharedLinkType.ALBUM,
createdAt: today.toISOString(), createdAt: today,
expiresAt: yesterday.toISOString(), expiresAt: yesterday,
allowUpload: true, allowUpload: true,
allowDownload: true, allowDownload: true,
showExif: true, showExif: true,
@ -672,8 +675,8 @@ export const sharedLinkStub = {
user: userEntityStub.admin, user: userEntityStub.admin,
key: Buffer.from('secret-key', 'utf8'), key: Buffer.from('secret-key', 'utf8'),
type: SharedLinkType.ALBUM, type: SharedLinkType.ALBUM,
createdAt: today.toISOString(), createdAt: today,
expiresAt: tomorrow.toISOString(), expiresAt: tomorrow,
allowUpload: false, allowUpload: false,
allowDownload: false, allowDownload: false,
showExif: true, showExif: true,
@ -683,8 +686,8 @@ export const sharedLinkStub = {
ownerId: authStub.admin.id, ownerId: authStub.admin.id,
owner: userEntityStub.admin, owner: userEntityStub.admin,
albumName: 'Test Album', albumName: 'Test Album',
createdAt: today.toISOString(), createdAt: today,
updatedAt: today.toISOString(), updatedAt: today,
albumThumbnailAsset: null, albumThumbnailAsset: null,
albumThumbnailAssetId: null, albumThumbnailAssetId: null,
sharedUsers: [], sharedUsers: [],
@ -763,9 +766,9 @@ export const sharedLinkResponseStub = {
allowDownload: true, allowDownload: true,
allowUpload: true, allowUpload: true,
assets: [], assets: [],
createdAt: today.toISOString(), createdAt: today,
description: undefined, description: undefined,
expiresAt: tomorrow.toISOString(), expiresAt: tomorrow,
id: '123', id: '123',
key: '7365637265742d6b6579', key: '7365637265742d6b6579',
showExif: true, showExif: true,
@ -777,9 +780,9 @@ export const sharedLinkResponseStub = {
allowDownload: true, allowDownload: true,
allowUpload: true, allowUpload: true,
assets: [], assets: [],
createdAt: today.toISOString(), createdAt: today,
description: undefined, description: undefined,
expiresAt: yesterday.toISOString(), expiresAt: yesterday,
id: '123', id: '123',
key: '7365637265742d6b6579', key: '7365637265742d6b6579',
showExif: true, showExif: true,
@ -791,8 +794,8 @@ export const sharedLinkResponseStub = {
userId: 'admin_id', userId: 'admin_id',
key: '7365637265742d6b6579', key: '7365637265742d6b6579',
type: SharedLinkType.ALBUM, type: SharedLinkType.ALBUM,
createdAt: today.toISOString(), createdAt: today,
expiresAt: tomorrow.toISOString(), expiresAt: tomorrow,
description: undefined, description: undefined,
allowUpload: false, allowUpload: false,
allowDownload: false, allowDownload: false,
@ -805,8 +808,8 @@ export const sharedLinkResponseStub = {
userId: 'admin_id', userId: 'admin_id',
key: '7365637265742d6b6579', key: '7365637265742d6b6579',
type: SharedLinkType.ALBUM, type: SharedLinkType.ALBUM,
createdAt: today.toISOString(), createdAt: today,
expiresAt: tomorrow.toISOString(), expiresAt: tomorrow,
description: undefined, description: undefined,
allowUpload: false, allowUpload: false,
allowDownload: false, allowDownload: false,

View File

@ -28,10 +28,10 @@ export class AlbumEntity {
albumName!: string; albumName!: string;
@CreateDateColumn({ type: 'timestamptz' }) @CreateDateColumn({ type: 'timestamptz' })
createdAt!: string; createdAt!: Date;
@UpdateDateColumn({ type: 'timestamptz' }) @UpdateDateColumn({ type: 'timestamptz' })
updatedAt!: string; updatedAt!: Date;
@ManyToOne(() => AssetEntity, { nullable: true, onDelete: 'SET NULL', onUpdate: 'CASCADE' }) @ManyToOne(() => AssetEntity, { nullable: true, onDelete: 'SET NULL', onUpdate: 'CASCADE' })
albumThumbnailAsset!: AssetEntity | null; albumThumbnailAsset!: AssetEntity | null;

View File

@ -19,8 +19,8 @@ export class APIKeyEntity {
userId!: string; userId!: string;
@CreateDateColumn({ type: 'timestamptz' }) @CreateDateColumn({ type: 'timestamptz' })
createdAt!: string; createdAt!: Date;
@UpdateDateColumn({ type: 'timestamptz' }) @UpdateDateColumn({ type: 'timestamptz' })
updatedAt!: string; updatedAt!: Date;
} }

View File

@ -35,10 +35,10 @@ export class SharedLinkEntity {
type!: SharedLinkType; type!: SharedLinkType;
@CreateDateColumn({ type: 'timestamptz' }) @CreateDateColumn({ type: 'timestamptz' })
createdAt!: string; createdAt!: Date;
@Column({ type: 'timestamptz', nullable: true }) @Column({ type: 'timestamptz', nullable: true })
expiresAt!: string | null; expiresAt!: Date | null;
@Column({ type: 'boolean', default: false }) @Column({ type: 'boolean', default: false })
allowUpload!: boolean; allowUpload!: boolean;

View File

@ -42,14 +42,14 @@ export class UserEntity {
@Column({ default: true }) @Column({ default: true })
shouldChangePassword!: boolean; shouldChangePassword!: boolean;
@CreateDateColumn() @CreateDateColumn({ type: 'timestamptz' })
createdAt!: string; createdAt!: Date;
@DeleteDateColumn() @DeleteDateColumn({ type: 'timestamptz' })
deletedAt?: Date; deletedAt!: Date | null;
@UpdateDateColumn({ type: 'timestamptz' }) @UpdateDateColumn({ type: 'timestamptz' })
updatedAt!: string; updatedAt!: Date;
@OneToMany(() => TagEntity, (tag) => tag.user) @OneToMany(() => TagEntity, (tag) => tag.user)
tags!: TagEntity[]; tags!: TagEntity[];

View File

@ -0,0 +1,16 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UserDatesTimestamptz1685370430343 implements MigrationInterface {
name = 'UserDatesTimestamptz1685370430343'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "users" ALTER COLUMN "createdAt" TYPE TIMESTAMP WITH TIME ZONE`);
await queryRunner.query(`ALTER TABLE "users" ALTER COLUMN "deletedAt" TYPE TIMESTAMP WITH TIME ZONE`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "users" ALTER COLUMN "deletedAt" TYPE TIMESTAMP`);
await queryRunner.query(`ALTER TABLE "users" ALTER COLUMN "createdAt" TYPE TIMESTAMP`);
}
}

View File

@ -2712,12 +2712,6 @@ export interface UserResponseDto {
* @memberof UserResponseDto * @memberof UserResponseDto
*/ */
'storageLabel': string | null; 'storageLabel': string | null;
/**
*
* @type {string}
* @memberof UserResponseDto
*/
'createdAt': string;
/** /**
* *
* @type {string} * @type {string}
@ -2741,13 +2735,19 @@ export interface UserResponseDto {
* @type {string} * @type {string}
* @memberof UserResponseDto * @memberof UserResponseDto
*/ */
'deletedAt'?: string; 'createdAt': string;
/** /**
* *
* @type {string} * @type {string}
* @memberof UserResponseDto * @memberof UserResponseDto
*/ */
'updatedAt'?: string; 'deletedAt': string | null;
/**
*
* @type {string}
* @memberof UserResponseDto
*/
'updatedAt': string;
/** /**
* *
* @type {string} * @type {string}