From 6d9e7694b1361527660fa4f30d506964ed9daeb9 Mon Sep 17 00:00:00 2001 From: Daniel Dietzler <36593685+danieldietzler@users.noreply.github.com> Date: Wed, 20 Mar 2024 23:53:07 +0100 Subject: [PATCH] chore(server): move dtos (#8131) move dtos --- server/e2e/client/asset-api.ts | 2 +- server/e2e/client/auth-api.ts | 4 +- server/e2e/client/library-api.ts | 2 +- .../jobs/specs/library-watcher.e2e-spec.ts | 4 +- server/e2e/jobs/specs/library.e2e-spec.ts | 2 +- .../commands/reset-admin-password.command.ts | 2 +- server/src/controllers/activity.controller.ts | 6 +- server/src/controllers/album.controller.ts | 19 +- server/src/controllers/api-key.controller.ts | 9 +- server/src/controllers/asset.controller.ts | 23 ++- server/src/controllers/audit.controller.ts | 6 +- server/src/controllers/auth.controller.ts | 6 +- server/src/controllers/download.controller.ts | 6 +- server/src/controllers/face.controller.ts | 4 +- server/src/controllers/job.controller.ts | 2 +- server/src/controllers/library.controller.ts | 4 +- server/src/controllers/oauth.controller.ts | 6 +- server/src/controllers/partner.controller.ts | 4 +- server/src/controllers/person.controller.ts | 10 +- server/src/controllers/search.controller.ts | 16 +- .../src/controllers/server-info.controller.ts | 4 +- .../src/controllers/shared-link.controller.ts | 14 +- .../controllers/system-config.controller.ts | 4 +- server/src/controllers/tag.controller.ts | 11 +- server/src/controllers/trash.controller.ts | 4 +- server/src/controllers/user.controller.ts | 10 +- server/src/cores/access.core.ts | 2 +- server/src/cores/system-config.core.ts | 2 +- server/src/cores/user.core.ts | 2 +- .../src/domain/activity/activity.service.ts | 4 +- server/src/domain/activity/activity.spec.ts | 2 +- server/src/domain/album/album.service.spec.ts | 2 +- server/src/domain/album/album.service.ts | 16 +- .../domain/album/dto/album-add-users.dto.ts | 8 - .../src/domain/album/dto/album-create.dto.ts | 19 -- .../src/domain/album/dto/album-update.dto.ts | 25 --- server/src/domain/album/dto/album.dto.ts | 6 - server/src/domain/album/dto/get-albums.dto.ts | 19 -- server/src/domain/api-key/api-key.service.ts | 4 +- server/src/domain/asset/asset.service.spec.ts | 7 +- server/src/domain/asset/asset.service.ts | 39 ++-- server/src/domain/asset/dto/asset-ids.dto.ts | 20 --- .../domain/asset/dto/asset-statistics.dto.ts | 34 ---- server/src/domain/asset/dto/asset.dto.ts | 75 -------- server/src/domain/asset/dto/map-marker.dto.ts | 18 -- .../src/domain/asset/dto/memory-lane.dto.ts | 19 -- .../response-dto/map-marker-response.dto.ts | 21 --- .../response-dto/smart-info-response.dto.ts | 13 -- .../response-dto/time-bucket-response.dto.ts | 9 - server/src/domain/audit/audit.service.ts | 8 +- server/src/domain/auth/auth.service.spec.ts | 2 +- server/src/domain/auth/auth.service.ts | 4 +- .../domain/download/download.service.spec.ts | 2 +- .../src/domain/download/download.service.ts | 6 +- server/src/domain/job/job.service.ts | 4 +- .../domain/library/library.service.spec.ts | 2 +- server/src/domain/library/library.service.ts | 2 +- server/src/domain/media/media.service.ts | 2 +- server/src/domain/media/media.util.ts | 2 +- .../domain/partner/partner.service.spec.ts | 2 +- server/src/domain/partner/partner.service.ts | 6 +- .../src/domain/person/person.service.spec.ts | 4 +- server/src/domain/person/person.service.ts | 8 +- .../search/dto/search-suggestion.dto.ts | 34 ---- .../search-explore.response.dto.ts | 11 -- .../response-dto/search-response.dto.ts | 38 ---- .../src/domain/search/search.service.spec.ts | 4 +- server/src/domain/search/search.service.ts | 13 +- .../domain/server-info/server-info.service.ts | 2 +- .../src/domain/shared-link/shared-link.dto.ts | 75 -------- .../shared-link/shared-link.service.spec.ts | 2 +- .../domain/shared-link/shared-link.service.ts | 12 +- ...stem-config-template-storage-option.dto.ts | 10 -- .../system-config/system-config.service.ts | 4 +- server/src/domain/tag/tag.dto.ts | 21 --- server/src/domain/tag/tag.service.spec.ts | 2 +- server/src/domain/tag/tag.service.ts | 11 +- server/src/domain/trash/trash.service.ts | 4 +- .../user/dto/create-profile-image.dto.ts | 7 - server/src/domain/user/dto/create-user.dto.ts | 61 ------- server/src/domain/user/dto/delete-user.dto.ts | 6 - .../domain/user/dto/update-user.dto.spec.ts | 17 -- server/src/domain/user/dto/update-user.dto.ts | 52 ------ .../create-profile-image-response.dto.ts | 11 -- .../user/response-dto/user-response.dto.ts | 65 ------- server/src/domain/user/user.service.spec.ts | 3 +- server/src/domain/user/user.service.ts | 12 +- .../{domain/activity => dtos}/activity.dto.ts | 2 +- .../album => dtos}/album-response.dto.spec.ts | 2 +- .../album.dto.ts} | 97 ++++++++-- .../{domain/api-key => dtos}/api-key.dto.ts | 0 .../asset-ids.response.dto.ts} | 0 .../asset-response.dto.ts | 24 ++- server/src/dtos/asset.dto.ts | 132 ++++++++++++++ .../src/{domain/audit => dtos}/audit.dto.ts | 0 server/src/{domain/auth => dtos}/auth.dto.ts | 0 .../{domain/download => dtos}/download.dto.ts | 0 .../exif-response.dto.ts => dtos/exif.dto.ts} | 0 server/src/{domain/job => dtos}/job.dto.ts | 0 .../{domain/library => dtos}/library.dto.ts | 0 .../dto => dtos}/model-config.dto.ts | 0 .../{domain/partner => dtos}/partner.dto.ts | 2 +- .../src/{domain/person => dtos}/person.dto.ts | 2 +- .../{domain/search/dto => dtos}/search.dto.ts | 129 +++++++++++++ .../server-info => dtos}/server-info.dto.ts | 2 +- .../shared-link.dto.ts} | 76 +++++++- .../asset-stack.dto.ts => dtos/stack.dto.ts} | 0 .../dto => dtos}/system-config-ffmpeg.dto.ts | 0 .../dto => dtos}/system-config-job.dto.ts | 0 .../dto => dtos}/system-config-library.dto.ts | 0 .../dto => dtos}/system-config-logging.dto.ts | 0 .../system-config-machine-learning.dto.ts | 2 +- .../dto => dtos}/system-config-map.dto.ts | 0 .../system-config-new-version-check.dto.ts | 0 .../dto => dtos}/system-config-oauth.dto.ts | 0 .../system-config-password-login.dto.ts | 0 .../system-config-reverse-geocoding.dto.ts | 0 .../dto => dtos}/system-config-server.dto.ts | 0 .../system-config-storage-template.dto.ts | 11 ++ .../dto => dtos}/system-config-theme.dto.ts | 0 .../system-config-thumbnail.dto.ts | 0 .../dto => dtos}/system-config-trash.dto.ts | 0 .../dto => dtos}/system-config-user.dto.ts | 0 .../dto => dtos}/system-config.dto.ts | 32 ++-- .../tag-response.dto.ts => dtos/tag.dto.ts} | 19 ++ .../asset/dto => dtos}/time-bucket.dto.ts | 8 + server/src/dtos/user-profile.dto.ts | 28 +++ .../user.dto.spec.ts} | 16 +- server/src/dtos/user.dto.ts | 169 ++++++++++++++++++ .../immich/api-v1/asset/asset.controller.ts | 4 +- .../src/immich/api-v1/asset/asset.service.ts | 4 +- .../api-v1/asset/dto/create-asset.dto.ts | 2 +- .../interfaces/communication.repository.ts | 4 +- server/src/interfaces/library.repository.ts | 2 +- .../interfaces/machine-learning.repository.ts | 2 +- server/src/interfaces/storage.repository.ts | 2 +- server/src/middleware/auth.guard.ts | 2 +- .../src/middleware/file-upload.interceptor.ts | 3 +- .../repositories/filesystem.provider.spec.ts | 2 +- .../src/repositories/filesystem.provider.ts | 2 +- server/src/repositories/library.repository.ts | 2 +- .../machine-learning.repository.ts | 2 +- server/test/fixtures/auth.stub.ts | 2 +- server/test/fixtures/shared-link.stub.ts | 10 +- server/test/fixtures/tag.stub.ts | 2 +- 145 files changed, 917 insertions(+), 964 deletions(-) delete mode 100644 server/src/domain/album/dto/album-add-users.dto.ts delete mode 100644 server/src/domain/album/dto/album-create.dto.ts delete mode 100644 server/src/domain/album/dto/album-update.dto.ts delete mode 100644 server/src/domain/album/dto/album.dto.ts delete mode 100644 server/src/domain/album/dto/get-albums.dto.ts delete mode 100644 server/src/domain/asset/dto/asset-ids.dto.ts delete mode 100644 server/src/domain/asset/dto/asset-statistics.dto.ts delete mode 100644 server/src/domain/asset/dto/asset.dto.ts delete mode 100644 server/src/domain/asset/dto/map-marker.dto.ts delete mode 100644 server/src/domain/asset/dto/memory-lane.dto.ts delete mode 100644 server/src/domain/asset/response-dto/map-marker-response.dto.ts delete mode 100644 server/src/domain/asset/response-dto/smart-info-response.dto.ts delete mode 100644 server/src/domain/asset/response-dto/time-bucket-response.dto.ts delete mode 100644 server/src/domain/search/dto/search-suggestion.dto.ts delete mode 100644 server/src/domain/search/response-dto/search-explore.response.dto.ts delete mode 100644 server/src/domain/search/response-dto/search-response.dto.ts delete mode 100644 server/src/domain/shared-link/shared-link.dto.ts delete mode 100644 server/src/domain/system-config/response-dto/system-config-template-storage-option.dto.ts delete mode 100644 server/src/domain/tag/tag.dto.ts delete mode 100644 server/src/domain/user/dto/create-profile-image.dto.ts delete mode 100644 server/src/domain/user/dto/create-user.dto.ts delete mode 100644 server/src/domain/user/dto/delete-user.dto.ts delete mode 100644 server/src/domain/user/dto/update-user.dto.spec.ts delete mode 100644 server/src/domain/user/dto/update-user.dto.ts delete mode 100644 server/src/domain/user/response-dto/create-profile-image-response.dto.ts delete mode 100644 server/src/domain/user/response-dto/user-response.dto.ts rename server/src/{domain/activity => dtos}/activity.dto.ts (95%) rename server/src/{domain/album => dtos}/album-response.dto.spec.ts (89%) rename server/src/{domain/album/album-response.dto.ts => dtos/album.dto.ts} (59%) rename server/src/{domain/api-key => dtos}/api-key.dto.ts (100%) rename server/src/{domain/asset/response-dto/asset-ids-response.dto.ts => dtos/asset-ids.response.dto.ts} (100%) rename server/src/{domain/asset/response-dto => dtos}/asset-response.dto.ts (88%) create mode 100644 server/src/dtos/asset.dto.ts rename server/src/{domain/audit => dtos}/audit.dto.ts (100%) rename server/src/{domain/auth => dtos}/auth.dto.ts (100%) rename server/src/{domain/download => dtos}/download.dto.ts (100%) rename server/src/{domain/asset/response-dto/exif-response.dto.ts => dtos/exif.dto.ts} (100%) rename server/src/{domain/job => dtos}/job.dto.ts (100%) rename server/src/{domain/library => dtos}/library.dto.ts (100%) rename server/src/{domain/smart-info/dto => dtos}/model-config.dto.ts (100%) rename server/src/{domain/partner => dtos}/partner.dto.ts (71%) rename server/src/{domain/person => dtos}/person.dto.ts (98%) rename server/src/{domain/search/dto => dtos}/search.dto.ts (66%) rename server/src/{domain/server-info => dtos}/server-info.dto.ts (96%) rename server/src/{domain/shared-link/shared-link-response.dto.ts => dtos/shared-link.dto.ts} (57%) rename server/src/{domain/asset/dto/asset-stack.dto.ts => dtos/stack.dto.ts} (100%) rename server/src/{domain/system-config/dto => dtos}/system-config-ffmpeg.dto.ts (100%) rename server/src/{domain/system-config/dto => dtos}/system-config-job.dto.ts (100%) rename server/src/{domain/system-config/dto => dtos}/system-config-library.dto.ts (100%) rename server/src/{domain/system-config/dto => dtos}/system-config-logging.dto.ts (100%) rename server/src/{domain/system-config/dto => dtos}/system-config-machine-learning.dto.ts (85%) rename server/src/{domain/system-config/dto => dtos}/system-config-map.dto.ts (100%) rename server/src/{domain/system-config/dto => dtos}/system-config-new-version-check.dto.ts (100%) rename server/src/{domain/system-config/dto => dtos}/system-config-oauth.dto.ts (100%) rename server/src/{domain/system-config/dto => dtos}/system-config-password-login.dto.ts (100%) rename server/src/{domain/system-config/dto => dtos}/system-config-reverse-geocoding.dto.ts (100%) rename server/src/{domain/system-config/dto => dtos}/system-config-server.dto.ts (100%) rename server/src/{domain/system-config/dto => dtos}/system-config-storage-template.dto.ts (53%) rename server/src/{domain/system-config/dto => dtos}/system-config-theme.dto.ts (100%) rename server/src/{domain/system-config/dto => dtos}/system-config-thumbnail.dto.ts (100%) rename server/src/{domain/system-config/dto => dtos}/system-config-trash.dto.ts (100%) rename server/src/{domain/system-config/dto => dtos}/system-config-user.dto.ts (100%) rename server/src/{domain/system-config/dto => dtos}/system-config.dto.ts (56%) rename server/src/{domain/tag/tag-response.dto.ts => dtos/tag.dto.ts} (54%) rename server/src/{domain/asset/dto => dtos}/time-bucket.dto.ts (88%) create mode 100644 server/src/dtos/user-profile.dto.ts rename server/src/{domain/user/dto/create-user.dto.spec.ts => dtos/user.dto.spec.ts} (79%) create mode 100644 server/src/dtos/user.dto.ts diff --git a/server/e2e/client/asset-api.ts b/server/e2e/client/asset-api.ts index 8f30e1f4ab..f32d586115 100644 --- a/server/e2e/client/asset-api.ts +++ b/server/e2e/client/asset-api.ts @@ -1,4 +1,4 @@ -import { AssetResponseDto } from 'src/domain/asset/response-dto/asset-response.dto'; +import { AssetResponseDto } from 'src/dtos/asset-response.dto'; import request from 'supertest'; export const assetApi = { diff --git a/server/e2e/client/auth-api.ts b/server/e2e/client/auth-api.ts index 46b21fb98f..a8cfe4660a 100644 --- a/server/e2e/client/auth-api.ts +++ b/server/e2e/client/auth-api.ts @@ -1,5 +1,5 @@ -import { LoginResponseDto } from 'src/domain/auth/auth.dto'; -import { UserResponseDto } from 'src/domain/user/response-dto/user-response.dto'; +import { LoginResponseDto } from 'src/dtos/auth.dto'; +import { UserResponseDto } from 'src/dtos/user.dto'; import request from 'supertest'; import { adminSignupStub, loginResponseStub, loginStub } from 'test/fixtures/auth.stub'; diff --git a/server/e2e/client/library-api.ts b/server/e2e/client/library-api.ts index 90b1b74517..70c8c4c360 100644 --- a/server/e2e/client/library-api.ts +++ b/server/e2e/client/library-api.ts @@ -1,4 +1,4 @@ -import { CreateLibraryDto, LibraryResponseDto, ScanLibraryDto } from 'src/domain/library/library.dto'; +import { CreateLibraryDto, LibraryResponseDto, ScanLibraryDto } from 'src/dtos/library.dto'; import request from 'supertest'; export const libraryApi = { diff --git a/server/e2e/jobs/specs/library-watcher.e2e-spec.ts b/server/e2e/jobs/specs/library-watcher.e2e-spec.ts index 3d43227b7b..0a005c7d54 100644 --- a/server/e2e/jobs/specs/library-watcher.e2e-spec.ts +++ b/server/e2e/jobs/specs/library-watcher.e2e-spec.ts @@ -1,9 +1,9 @@ import { api } from 'e2e/client'; import fs from 'node:fs/promises'; import path from 'node:path'; -import { LoginResponseDto } from 'src/domain/auth/auth.dto'; -import { LibraryResponseDto } from 'src/domain/library/library.dto'; import { LibraryService } from 'src/domain/library/library.service'; +import { LoginResponseDto } from 'src/dtos/auth.dto'; +import { LibraryResponseDto } from 'src/dtos/library.dto'; import { AssetType } from 'src/entities/asset.entity'; import { LibraryType } from 'src/entities/library.entity'; import { StorageEventType } from 'src/interfaces/storage.repository'; diff --git a/server/e2e/jobs/specs/library.e2e-spec.ts b/server/e2e/jobs/specs/library.e2e-spec.ts index 657c53fc24..3ae27e631e 100644 --- a/server/e2e/jobs/specs/library.e2e-spec.ts +++ b/server/e2e/jobs/specs/library.e2e-spec.ts @@ -1,7 +1,7 @@ import { api } from 'e2e/client'; import fs from 'node:fs'; import { LibraryController } from 'src/controllers/library.controller'; -import { LoginResponseDto } from 'src/domain/auth/auth.dto'; +import { LoginResponseDto } from 'src/dtos/auth.dto'; import { LibraryType } from 'src/entities/library.entity'; import request from 'supertest'; import { errorStub } from 'test/fixtures/error.stub'; diff --git a/server/src/commands/reset-admin-password.command.ts b/server/src/commands/reset-admin-password.command.ts index ce0a897a88..b67ef418e5 100644 --- a/server/src/commands/reset-admin-password.command.ts +++ b/server/src/commands/reset-admin-password.command.ts @@ -1,6 +1,6 @@ import { Command, CommandRunner, InquirerService, Question, QuestionSet } from 'nest-commander'; -import { UserResponseDto } from 'src/domain/user/response-dto/user-response.dto'; import { UserService } from 'src/domain/user/user.service'; +import { UserResponseDto } from 'src/dtos/user.dto'; @Command({ name: 'reset-admin-password', diff --git a/server/src/controllers/activity.controller.ts b/server/src/controllers/activity.controller.ts index c405b0c6f5..92e8797aad 100644 --- a/server/src/controllers/activity.controller.ts +++ b/server/src/controllers/activity.controller.ts @@ -1,15 +1,15 @@ import { Body, Controller, Delete, Get, HttpCode, HttpStatus, Param, Post, Query, Res } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; import { Response } from 'express'; +import { ActivityService } from 'src/domain/activity/activity.service'; import { ActivityCreateDto, ActivityDto, ActivityResponseDto, ActivitySearchDto, ActivityStatisticsResponseDto, -} from 'src/domain/activity/activity.dto'; -import { ActivityService } from 'src/domain/activity/activity.service'; -import { AuthDto } from 'src/domain/auth/auth.dto'; +} from 'src/dtos/activity.dto'; +import { AuthDto } from 'src/dtos/auth.dto'; import { Auth, Authenticated } from 'src/middleware/auth.guard'; import { UUIDParamDto } from 'src/validation'; diff --git a/server/src/controllers/album.controller.ts b/server/src/controllers/album.controller.ts index 18fd549b6e..7cc39a860d 100644 --- a/server/src/controllers/album.controller.ts +++ b/server/src/controllers/album.controller.ts @@ -1,14 +1,17 @@ import { Body, Controller, Delete, Get, Param, Patch, Post, Put, Query } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; -import { AlbumCountResponseDto, AlbumResponseDto } from 'src/domain/album/album-response.dto'; import { AlbumService } from 'src/domain/album/album.service'; -import { AddUsersDto } from 'src/domain/album/dto/album-add-users.dto'; -import { CreateAlbumDto } from 'src/domain/album/dto/album-create.dto'; -import { UpdateAlbumDto } from 'src/domain/album/dto/album-update.dto'; -import { AlbumInfoDto } from 'src/domain/album/dto/album.dto'; -import { GetAlbumsDto } from 'src/domain/album/dto/get-albums.dto'; -import { BulkIdResponseDto, BulkIdsDto } from 'src/domain/asset/response-dto/asset-ids-response.dto'; -import { AuthDto } from 'src/domain/auth/auth.dto'; +import { + AddUsersDto, + AlbumCountResponseDto, + AlbumInfoDto, + AlbumResponseDto, + CreateAlbumDto, + GetAlbumsDto, + UpdateAlbumDto, +} from 'src/dtos/album.dto'; +import { BulkIdResponseDto, BulkIdsDto } from 'src/dtos/asset-ids.response.dto'; +import { AuthDto } from 'src/dtos/auth.dto'; import { Auth, Authenticated, SharedLinkRoute } from 'src/middleware/auth.guard'; import { ParseMeUUIDPipe, UUIDParamDto } from 'src/validation'; diff --git a/server/src/controllers/api-key.controller.ts b/server/src/controllers/api-key.controller.ts index 2d4f8db155..9b6838f8d2 100644 --- a/server/src/controllers/api-key.controller.ts +++ b/server/src/controllers/api-key.controller.ts @@ -1,13 +1,8 @@ import { Body, Controller, Delete, Get, Param, Post, Put } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; -import { - APIKeyCreateDto, - APIKeyCreateResponseDto, - APIKeyResponseDto, - APIKeyUpdateDto, -} from 'src/domain/api-key/api-key.dto'; import { APIKeyService } from 'src/domain/api-key/api-key.service'; -import { AuthDto } from 'src/domain/auth/auth.dto'; +import { APIKeyCreateDto, APIKeyCreateResponseDto, APIKeyResponseDto, APIKeyUpdateDto } from 'src/dtos/api-key.dto'; +import { AuthDto } from 'src/dtos/auth.dto'; import { Auth, Authenticated } from 'src/middleware/auth.guard'; import { UUIDParamDto } from 'src/validation'; diff --git a/server/src/controllers/asset.controller.ts b/server/src/controllers/asset.controller.ts index a6db598156..ca44aedfe9 100644 --- a/server/src/controllers/asset.controller.ts +++ b/server/src/controllers/asset.controller.ts @@ -1,25 +1,22 @@ import { Body, Controller, Delete, Get, HttpCode, HttpStatus, Param, Post, Put, Query } from '@nestjs/common'; import { ApiOperation, ApiTags } from '@nestjs/swagger'; import { AssetService } from 'src/domain/asset/asset.service'; -import { AssetJobsDto } from 'src/domain/asset/dto/asset-ids.dto'; -import { UpdateStackParentDto } from 'src/domain/asset/dto/asset-stack.dto'; -import { AssetStatsDto, AssetStatsResponseDto } from 'src/domain/asset/dto/asset-statistics.dto'; +import { SearchService } from 'src/domain/search/search.service'; +import { AssetResponseDto, MemoryLaneResponseDto } from 'src/dtos/asset-response.dto'; import { AssetBulkDeleteDto, AssetBulkUpdateDto, + AssetJobsDto, + AssetStatsDto, + AssetStatsResponseDto, DeviceIdDto, RandomAssetsDto, UpdateAssetDto, -} from 'src/domain/asset/dto/asset.dto'; -import { MapMarkerDto } from 'src/domain/asset/dto/map-marker.dto'; -import { MemoryLaneDto } from 'src/domain/asset/dto/memory-lane.dto'; -import { TimeBucketAssetDto, TimeBucketDto } from 'src/domain/asset/dto/time-bucket.dto'; -import { AssetResponseDto, MemoryLaneResponseDto } from 'src/domain/asset/response-dto/asset-response.dto'; -import { MapMarkerResponseDto } from 'src/domain/asset/response-dto/map-marker-response.dto'; -import { TimeBucketResponseDto } from 'src/domain/asset/response-dto/time-bucket-response.dto'; -import { AuthDto } from 'src/domain/auth/auth.dto'; -import { MetadataSearchDto } from 'src/domain/search/dto/search.dto'; -import { SearchService } from 'src/domain/search/search.service'; +} from 'src/dtos/asset.dto'; +import { AuthDto } from 'src/dtos/auth.dto'; +import { MapMarkerDto, MapMarkerResponseDto, MemoryLaneDto, MetadataSearchDto } from 'src/dtos/search.dto'; +import { UpdateStackParentDto } from 'src/dtos/stack.dto'; +import { TimeBucketAssetDto, TimeBucketDto, TimeBucketResponseDto } from 'src/dtos/time-bucket.dto'; import { Auth, Authenticated, SharedLinkRoute } from 'src/middleware/auth.guard'; import { Route } from 'src/middleware/file-upload.interceptor'; import { UUIDParamDto } from 'src/validation'; diff --git a/server/src/controllers/audit.controller.ts b/server/src/controllers/audit.controller.ts index bb92f990e7..b4d27b4ce7 100644 --- a/server/src/controllers/audit.controller.ts +++ b/server/src/controllers/audit.controller.ts @@ -1,5 +1,6 @@ import { Body, Controller, Get, Post, Query } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; +import { AuditService } from 'src/domain/audit/audit.service'; import { AuditDeletesDto, AuditDeletesResponseDto, @@ -7,9 +8,8 @@ import { FileChecksumResponseDto, FileReportDto, FileReportFixDto, -} from 'src/domain/audit/audit.dto'; -import { AuditService } from 'src/domain/audit/audit.service'; -import { AuthDto } from 'src/domain/auth/auth.dto'; +} from 'src/dtos/audit.dto'; +import { AuthDto } from 'src/dtos/auth.dto'; import { AdminRoute, Auth, Authenticated } from 'src/middleware/auth.guard'; @ApiTags('Audit') diff --git a/server/src/controllers/auth.controller.ts b/server/src/controllers/auth.controller.ts index 941002fe64..6197c1e5fe 100644 --- a/server/src/controllers/auth.controller.ts +++ b/server/src/controllers/auth.controller.ts @@ -2,6 +2,7 @@ import { Body, Controller, Delete, Get, HttpCode, HttpStatus, Param, Post, Req, import { ApiTags } from '@nestjs/swagger'; import { Request, Response } from 'express'; import { IMMICH_ACCESS_COOKIE, IMMICH_AUTH_TYPE_COOKIE, IMMICH_IS_AUTHENTICATED } from 'src/domain/auth/auth.constant'; +import { AuthService, LoginDetails } from 'src/domain/auth/auth.service'; import { AuthDeviceResponseDto, AuthDto, @@ -11,9 +12,8 @@ import { LogoutResponseDto, SignUpDto, ValidateAccessTokenResponseDto, -} from 'src/domain/auth/auth.dto'; -import { AuthService, LoginDetails } from 'src/domain/auth/auth.service'; -import { UserResponseDto, mapUser } from 'src/domain/user/response-dto/user-response.dto'; +} from 'src/dtos/auth.dto'; +import { UserResponseDto, mapUser } from 'src/dtos/user.dto'; import { Auth, Authenticated, GetLoginDetails, PublicRoute } from 'src/middleware/auth.guard'; import { UUIDParamDto } from 'src/validation'; diff --git a/server/src/controllers/download.controller.ts b/server/src/controllers/download.controller.ts index 0fb3520cfe..8ba5d4281a 100644 --- a/server/src/controllers/download.controller.ts +++ b/server/src/controllers/download.controller.ts @@ -1,10 +1,10 @@ import { Body, Controller, HttpCode, HttpStatus, Next, Param, Post, Res, StreamableFile } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; import { NextFunction, Response } from 'express'; -import { AssetIdsDto } from 'src/domain/asset/dto/asset-ids.dto'; -import { AuthDto } from 'src/domain/auth/auth.dto'; -import { DownloadInfoDto, DownloadResponseDto } from 'src/domain/download/download.dto'; import { DownloadService } from 'src/domain/download/download.service'; +import { AssetIdsDto } from 'src/dtos/asset.dto'; +import { AuthDto } from 'src/dtos/auth.dto'; +import { DownloadInfoDto, DownloadResponseDto } from 'src/dtos/download.dto'; import { asStreamableFile, sendFile } from 'src/immich/app.utils'; import { Auth, Authenticated, FileResponse, SharedLinkRoute } from 'src/middleware/auth.guard'; import { UUIDParamDto } from 'src/validation'; diff --git a/server/src/controllers/face.controller.ts b/server/src/controllers/face.controller.ts index c7caba0161..d5712d6b79 100644 --- a/server/src/controllers/face.controller.ts +++ b/server/src/controllers/face.controller.ts @@ -1,8 +1,8 @@ import { Body, Controller, Get, Param, Put, Query } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; -import { AuthDto } from 'src/domain/auth/auth.dto'; -import { AssetFaceResponseDto, FaceDto, PersonResponseDto } from 'src/domain/person/person.dto'; import { PersonService } from 'src/domain/person/person.service'; +import { AuthDto } from 'src/dtos/auth.dto'; +import { AssetFaceResponseDto, FaceDto, PersonResponseDto } from 'src/dtos/person.dto'; import { Auth, Authenticated } from 'src/middleware/auth.guard'; import { UUIDParamDto } from 'src/validation'; diff --git a/server/src/controllers/job.controller.ts b/server/src/controllers/job.controller.ts index f0e9ed2be8..04dea79eec 100644 --- a/server/src/controllers/job.controller.ts +++ b/server/src/controllers/job.controller.ts @@ -1,7 +1,7 @@ import { Body, Controller, Get, Param, Put } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; -import { AllJobStatusResponseDto, JobCommandDto, JobIdParamDto, JobStatusDto } from 'src/domain/job/job.dto'; import { JobService } from 'src/domain/job/job.service'; +import { AllJobStatusResponseDto, JobCommandDto, JobIdParamDto, JobStatusDto } from 'src/dtos/job.dto'; import { Authenticated } from 'src/middleware/auth.guard'; @ApiTags('Job') diff --git a/server/src/controllers/library.controller.ts b/server/src/controllers/library.controller.ts index 677773f2dc..96c5f74152 100644 --- a/server/src/controllers/library.controller.ts +++ b/server/src/controllers/library.controller.ts @@ -1,5 +1,6 @@ import { Body, Controller, Delete, Get, HttpCode, HttpStatus, Param, Post, Put, Query } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; +import { LibraryService } from 'src/domain/library/library.service'; import { CreateLibraryDto, LibraryResponseDto, @@ -9,8 +10,7 @@ import { UpdateLibraryDto, ValidateLibraryDto, ValidateLibraryResponseDto, -} from 'src/domain/library/library.dto'; -import { LibraryService } from 'src/domain/library/library.service'; +} from 'src/dtos/library.dto'; import { AdminRoute, Authenticated } from 'src/middleware/auth.guard'; import { UUIDParamDto } from 'src/validation'; diff --git a/server/src/controllers/oauth.controller.ts b/server/src/controllers/oauth.controller.ts index 48b3eafd5e..6da9faa173 100644 --- a/server/src/controllers/oauth.controller.ts +++ b/server/src/controllers/oauth.controller.ts @@ -1,15 +1,15 @@ import { Body, Controller, Get, HttpStatus, Post, Redirect, Req, Res } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; import { Request, Response } from 'express'; +import { AuthService, LoginDetails } from 'src/domain/auth/auth.service'; import { AuthDto, LoginResponseDto, OAuthAuthorizeResponseDto, OAuthCallbackDto, OAuthConfigDto, -} from 'src/domain/auth/auth.dto'; -import { AuthService, LoginDetails } from 'src/domain/auth/auth.service'; -import { UserResponseDto } from 'src/domain/user/response-dto/user-response.dto'; +} from 'src/dtos/auth.dto'; +import { UserResponseDto } from 'src/dtos/user.dto'; import { Auth, Authenticated, GetLoginDetails, PublicRoute } from 'src/middleware/auth.guard'; @ApiTags('OAuth') diff --git a/server/src/controllers/partner.controller.ts b/server/src/controllers/partner.controller.ts index 8ca55e73c8..c4f22a04f0 100644 --- a/server/src/controllers/partner.controller.ts +++ b/server/src/controllers/partner.controller.ts @@ -1,8 +1,8 @@ import { Body, Controller, Delete, Get, Param, Post, Put, Query } from '@nestjs/common'; import { ApiQuery, ApiTags } from '@nestjs/swagger'; -import { AuthDto } from 'src/domain/auth/auth.dto'; -import { PartnerResponseDto, UpdatePartnerDto } from 'src/domain/partner/partner.dto'; import { PartnerService } from 'src/domain/partner/partner.service'; +import { AuthDto } from 'src/dtos/auth.dto'; +import { PartnerResponseDto, UpdatePartnerDto } from 'src/dtos/partner.dto'; import { PartnerDirection } from 'src/interfaces/partner.repository'; import { Auth, Authenticated } from 'src/middleware/auth.guard'; import { UUIDParamDto } from 'src/validation'; diff --git a/server/src/controllers/person.controller.ts b/server/src/controllers/person.controller.ts index bc955fd2c2..9c5602091a 100644 --- a/server/src/controllers/person.controller.ts +++ b/server/src/controllers/person.controller.ts @@ -1,9 +1,10 @@ import { Body, Controller, Get, Next, Param, Post, Put, Query, Res } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; import { NextFunction, Response } from 'express'; -import { BulkIdResponseDto } from 'src/domain/asset/response-dto/asset-ids-response.dto'; -import { AssetResponseDto } from 'src/domain/asset/response-dto/asset-response.dto'; -import { AuthDto } from 'src/domain/auth/auth.dto'; +import { PersonService } from 'src/domain/person/person.service'; +import { BulkIdResponseDto } from 'src/dtos/asset-ids.response.dto'; +import { AssetResponseDto } from 'src/dtos/asset-response.dto'; +import { AuthDto } from 'src/dtos/auth.dto'; import { AssetFaceUpdateDto, MergePersonDto, @@ -14,8 +15,7 @@ import { PersonSearchDto, PersonStatisticsResponseDto, PersonUpdateDto, -} from 'src/domain/person/person.dto'; -import { PersonService } from 'src/domain/person/person.service'; +} from 'src/dtos/person.dto'; import { sendFile } from 'src/immich/app.utils'; import { Auth, Authenticated, FileResponse } from 'src/middleware/auth.guard'; import { UUIDParamDto } from 'src/validation'; diff --git a/server/src/controllers/search.controller.ts b/server/src/controllers/search.controller.ts index 76fce16096..6b88f5ad81 100644 --- a/server/src/controllers/search.controller.ts +++ b/server/src/controllers/search.controller.ts @@ -1,20 +1,20 @@ import { Body, Controller, Get, HttpCode, HttpStatus, Post, Query } from '@nestjs/common'; import { ApiOperation, ApiTags } from '@nestjs/swagger'; -import { AssetResponseDto } from 'src/domain/asset/response-dto/asset-response.dto'; -import { AuthDto } from 'src/domain/auth/auth.dto'; -import { PersonResponseDto } from 'src/domain/person/person.dto'; -import { SearchSuggestionRequestDto } from 'src/domain/search/dto/search-suggestion.dto'; +import { SearchService } from 'src/domain/search/search.service'; +import { AssetResponseDto } from 'src/dtos/asset-response.dto'; +import { AuthDto } from 'src/dtos/auth.dto'; +import { PersonResponseDto } from 'src/dtos/person.dto'; import { MetadataSearchDto, PlacesResponseDto, SearchDto, + SearchExploreResponseDto, SearchPeopleDto, SearchPlacesDto, + SearchResponseDto, + SearchSuggestionRequestDto, SmartSearchDto, -} from 'src/domain/search/dto/search.dto'; -import { SearchExploreResponseDto } from 'src/domain/search/response-dto/search-explore.response.dto'; -import { SearchResponseDto } from 'src/domain/search/response-dto/search-response.dto'; -import { SearchService } from 'src/domain/search/search.service'; +} from 'src/dtos/search.dto'; import { Auth, Authenticated } from 'src/middleware/auth.guard'; @ApiTags('Search') diff --git a/server/src/controllers/server-info.controller.ts b/server/src/controllers/server-info.controller.ts index aae6174937..9937acde8a 100644 --- a/server/src/controllers/server-info.controller.ts +++ b/server/src/controllers/server-info.controller.ts @@ -1,5 +1,6 @@ import { Controller, Get, HttpCode, HttpStatus, Post } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; +import { ServerInfoService } from 'src/domain/server-info/server-info.service'; import { ServerConfigDto, ServerFeaturesDto, @@ -9,8 +10,7 @@ import { ServerStatsResponseDto, ServerThemeDto, ServerVersionResponseDto, -} from 'src/domain/server-info/server-info.dto'; -import { ServerInfoService } from 'src/domain/server-info/server-info.service'; +} from 'src/dtos/server-info.dto'; import { AdminRoute, Authenticated, PublicRoute } from 'src/middleware/auth.guard'; @ApiTags('Server Info') diff --git a/server/src/controllers/shared-link.controller.ts b/server/src/controllers/shared-link.controller.ts index 1e03a5c427..90bbd6ee13 100644 --- a/server/src/controllers/shared-link.controller.ts +++ b/server/src/controllers/shared-link.controller.ts @@ -1,13 +1,17 @@ import { Body, Controller, Delete, Get, Param, Patch, Post, Put, Query, Req, Res } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; import { Request, Response } from 'express'; -import { AssetIdsDto } from 'src/domain/asset/dto/asset-ids.dto'; -import { AssetIdsResponseDto } from 'src/domain/asset/response-dto/asset-ids-response.dto'; import { IMMICH_SHARED_LINK_ACCESS_COOKIE } from 'src/domain/auth/auth.constant'; -import { AuthDto } from 'src/domain/auth/auth.dto'; -import { SharedLinkResponseDto } from 'src/domain/shared-link/shared-link-response.dto'; -import { SharedLinkCreateDto, SharedLinkEditDto, SharedLinkPasswordDto } from 'src/domain/shared-link/shared-link.dto'; import { SharedLinkService } from 'src/domain/shared-link/shared-link.service'; +import { AssetIdsResponseDto } from 'src/dtos/asset-ids.response.dto'; +import { AssetIdsDto } from 'src/dtos/asset.dto'; +import { AuthDto } from 'src/dtos/auth.dto'; +import { + SharedLinkCreateDto, + SharedLinkEditDto, + SharedLinkPasswordDto, + SharedLinkResponseDto, +} from 'src/dtos/shared-link.dto'; import { Auth, Authenticated, SharedLinkRoute } from 'src/middleware/auth.guard'; import { UUIDParamDto } from 'src/validation'; diff --git a/server/src/controllers/system-config.controller.ts b/server/src/controllers/system-config.controller.ts index d10bccee05..34f9f2e0ed 100644 --- a/server/src/controllers/system-config.controller.ts +++ b/server/src/controllers/system-config.controller.ts @@ -1,9 +1,9 @@ import { Body, Controller, Get, Put, Query } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; -import { SystemConfigDto } from 'src/domain/system-config/dto/system-config.dto'; -import { SystemConfigTemplateStorageOptionDto } from 'src/domain/system-config/response-dto/system-config-template-storage-option.dto'; import { MapThemeDto } from 'src/domain/system-config/system-config-map-theme.dto'; import { SystemConfigService } from 'src/domain/system-config/system-config.service'; +import { SystemConfigTemplateStorageOptionDto } from 'src/dtos/system-config-storage-template.dto'; +import { SystemConfigDto } from 'src/dtos/system-config.dto'; import { AdminRoute, Authenticated } from 'src/middleware/auth.guard'; @ApiTags('System Config') diff --git a/server/src/controllers/tag.controller.ts b/server/src/controllers/tag.controller.ts index e914e577e1..bbca4a05d8 100644 --- a/server/src/controllers/tag.controller.ts +++ b/server/src/controllers/tag.controller.ts @@ -1,12 +1,11 @@ import { Body, Controller, Delete, Get, Param, Patch, Post, Put } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; -import { AssetIdsDto } from 'src/domain/asset/dto/asset-ids.dto'; -import { AssetIdsResponseDto } from 'src/domain/asset/response-dto/asset-ids-response.dto'; -import { AssetResponseDto } from 'src/domain/asset/response-dto/asset-response.dto'; -import { AuthDto } from 'src/domain/auth/auth.dto'; -import { TagResponseDto } from 'src/domain/tag/tag-response.dto'; -import { CreateTagDto, UpdateTagDto } from 'src/domain/tag/tag.dto'; import { TagService } from 'src/domain/tag/tag.service'; +import { AssetIdsResponseDto } from 'src/dtos/asset-ids.response.dto'; +import { AssetResponseDto } from 'src/dtos/asset-response.dto'; +import { AssetIdsDto } from 'src/dtos/asset.dto'; +import { AuthDto } from 'src/dtos/auth.dto'; +import { CreateTagDto, TagResponseDto, UpdateTagDto } from 'src/dtos/tag.dto'; import { Auth, Authenticated } from 'src/middleware/auth.guard'; import { UUIDParamDto } from 'src/validation'; diff --git a/server/src/controllers/trash.controller.ts b/server/src/controllers/trash.controller.ts index 2c0b0c946f..5ea692d486 100644 --- a/server/src/controllers/trash.controller.ts +++ b/server/src/controllers/trash.controller.ts @@ -1,8 +1,8 @@ import { Body, Controller, HttpCode, HttpStatus, Post } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; -import { BulkIdsDto } from 'src/domain/asset/response-dto/asset-ids-response.dto'; -import { AuthDto } from 'src/domain/auth/auth.dto'; import { TrashService } from 'src/domain/trash/trash.service'; +import { BulkIdsDto } from 'src/dtos/asset-ids.response.dto'; +import { AuthDto } from 'src/dtos/auth.dto'; import { Auth, Authenticated } from 'src/middleware/auth.guard'; @ApiTags('Trash') diff --git a/server/src/controllers/user.controller.ts b/server/src/controllers/user.controller.ts index e573584ad5..9fc0ff320e 100644 --- a/server/src/controllers/user.controller.ts +++ b/server/src/controllers/user.controller.ts @@ -16,14 +16,10 @@ import { } from '@nestjs/common'; import { ApiBody, ApiConsumes, ApiTags } from '@nestjs/swagger'; import { NextFunction, Response } from 'express'; -import { AuthDto } from 'src/domain/auth/auth.dto'; -import { CreateProfileImageDto } from 'src/domain/user/dto/create-profile-image.dto'; -import { CreateUserDto } from 'src/domain/user/dto/create-user.dto'; -import { DeleteUserDto } from 'src/domain/user/dto/delete-user.dto'; -import { UpdateUserDto } from 'src/domain/user/dto/update-user.dto'; -import { CreateProfileImageResponseDto } from 'src/domain/user/response-dto/create-profile-image-response.dto'; -import { UserResponseDto } from 'src/domain/user/response-dto/user-response.dto'; import { UserService } from 'src/domain/user/user.service'; +import { AuthDto } from 'src/dtos/auth.dto'; +import { CreateProfileImageDto, CreateProfileImageResponseDto } from 'src/dtos/user-profile.dto'; +import { CreateUserDto, DeleteUserDto, UpdateUserDto, UserResponseDto } from 'src/dtos/user.dto'; import { sendFile } from 'src/immich/app.utils'; import { AdminRoute, Auth, Authenticated, FileResponse } from 'src/middleware/auth.guard'; import { FileUploadInterceptor, Route } from 'src/middleware/file-upload.interceptor'; diff --git a/server/src/cores/access.core.ts b/server/src/cores/access.core.ts index f9e22bb6b2..1c0b1dabb6 100644 --- a/server/src/cores/access.core.ts +++ b/server/src/cores/access.core.ts @@ -1,5 +1,5 @@ import { BadRequestException, UnauthorizedException } from '@nestjs/common'; -import { AuthDto } from 'src/domain/auth/auth.dto'; +import { AuthDto } from 'src/dtos/auth.dto'; import { SharedLinkEntity } from 'src/entities/shared-link.entity'; import { IAccessRepository } from 'src/interfaces/access.repository'; import { setDifference, setIsEqual, setUnion } from 'src/utils'; diff --git a/server/src/cores/system-config.core.ts b/server/src/cores/system-config.core.ts index 295a0e5ed5..a6692fa185 100644 --- a/server/src/cores/system-config.core.ts +++ b/server/src/cores/system-config.core.ts @@ -6,7 +6,7 @@ import { load as loadYaml } from 'js-yaml'; import * as _ from 'lodash'; import { Subject } from 'rxjs'; import { QueueName } from 'src/domain/job/job.constants'; -import { SystemConfigDto } from 'src/domain/system-config/dto/system-config.dto'; +import { SystemConfigDto } from 'src/dtos/system-config.dto'; import { AudioCodec, CQMode, diff --git a/server/src/cores/user.core.ts b/server/src/cores/user.core.ts index d91f2bae59..1640e8d072 100644 --- a/server/src/cores/user.core.ts +++ b/server/src/cores/user.core.ts @@ -1,6 +1,6 @@ import { BadRequestException, ForbiddenException } from '@nestjs/common'; import sanitize from 'sanitize-filename'; -import { UserResponseDto } from 'src/domain/user/response-dto/user-response.dto'; +import { UserResponseDto } from 'src/dtos/user.dto'; import { LibraryType } from 'src/entities/library.entity'; import { UserEntity } from 'src/entities/user.entity'; import { ICryptoRepository } from 'src/interfaces/crypto.repository'; diff --git a/server/src/domain/activity/activity.service.ts b/server/src/domain/activity/activity.service.ts index 81d77fa8db..ff310cb5dc 100644 --- a/server/src/domain/activity/activity.service.ts +++ b/server/src/domain/activity/activity.service.ts @@ -10,8 +10,8 @@ import { ReactionLevel, ReactionType, mapActivity, -} from 'src/domain/activity/activity.dto'; -import { AuthDto } from 'src/domain/auth/auth.dto'; +} from 'src/dtos/activity.dto'; +import { AuthDto } from 'src/dtos/auth.dto'; import { ActivityEntity } from 'src/entities/activity.entity'; import { IAccessRepository } from 'src/interfaces/access.repository'; import { IActivityRepository } from 'src/interfaces/activity.repository'; diff --git a/server/src/domain/activity/activity.spec.ts b/server/src/domain/activity/activity.spec.ts index 467540be34..6013f0ff04 100644 --- a/server/src/domain/activity/activity.spec.ts +++ b/server/src/domain/activity/activity.spec.ts @@ -1,6 +1,6 @@ import { BadRequestException } from '@nestjs/common'; -import { ReactionType } from 'src/domain/activity/activity.dto'; import { ActivityService } from 'src/domain/activity/activity.service'; +import { ReactionType } from 'src/dtos/activity.dto'; import { IActivityRepository } from 'src/interfaces/activity.repository'; import { activityStub } from 'test/fixtures/activity.stub'; import { authStub } from 'test/fixtures/auth.stub'; diff --git a/server/src/domain/album/album.service.spec.ts b/server/src/domain/album/album.service.spec.ts index 5b3a91ecff..41b505ea6d 100644 --- a/server/src/domain/album/album.service.spec.ts +++ b/server/src/domain/album/album.service.spec.ts @@ -1,7 +1,7 @@ import { BadRequestException } from '@nestjs/common'; import _ from 'lodash'; import { AlbumService } from 'src/domain/album/album.service'; -import { BulkIdErrorReason } from 'src/domain/asset/response-dto/asset-ids-response.dto'; +import { BulkIdErrorReason } from 'src/dtos/asset-ids.response.dto'; import { IAlbumRepository } from 'src/interfaces/album.repository'; import { IAssetRepository } from 'src/interfaces/asset.repository'; import { IUserRepository } from 'src/interfaces/user.repository'; diff --git a/server/src/domain/album/album.service.ts b/server/src/domain/album/album.service.ts index 4d459ea44d..ea7178bedf 100644 --- a/server/src/domain/album/album.service.ts +++ b/server/src/domain/album/album.service.ts @@ -1,19 +1,19 @@ import { BadRequestException, Inject, Injectable } from '@nestjs/common'; import { AccessCore, Permission } from 'src/cores/access.core'; import { + AddUsersDto, AlbumCountResponseDto, + AlbumInfoDto, AlbumResponseDto, + CreateAlbumDto, + GetAlbumsDto, + UpdateAlbumDto, mapAlbum, mapAlbumWithAssets, mapAlbumWithoutAssets, -} from 'src/domain/album/album-response.dto'; -import { AddUsersDto } from 'src/domain/album/dto/album-add-users.dto'; -import { CreateAlbumDto } from 'src/domain/album/dto/album-create.dto'; -import { UpdateAlbumDto } from 'src/domain/album/dto/album-update.dto'; -import { AlbumInfoDto } from 'src/domain/album/dto/album.dto'; -import { GetAlbumsDto } from 'src/domain/album/dto/get-albums.dto'; -import { BulkIdErrorReason, BulkIdResponseDto, BulkIdsDto } from 'src/domain/asset/response-dto/asset-ids-response.dto'; -import { AuthDto } from 'src/domain/auth/auth.dto'; +} from 'src/dtos/album.dto'; +import { BulkIdErrorReason, BulkIdResponseDto, BulkIdsDto } from 'src/dtos/asset-ids.response.dto'; +import { AuthDto } from 'src/dtos/auth.dto'; import { AlbumEntity } from 'src/entities/album.entity'; import { AssetEntity } from 'src/entities/asset.entity'; import { UserEntity } from 'src/entities/user.entity'; diff --git a/server/src/domain/album/dto/album-add-users.dto.ts b/server/src/domain/album/dto/album-add-users.dto.ts deleted file mode 100644 index 1a6be48232..0000000000 --- a/server/src/domain/album/dto/album-add-users.dto.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { ArrayNotEmpty } from 'class-validator'; -import { ValidateUUID } from 'src/validation'; - -export class AddUsersDto { - @ValidateUUID({ each: true }) - @ArrayNotEmpty() - sharedUserIds!: string[]; -} diff --git a/server/src/domain/album/dto/album-create.dto.ts b/server/src/domain/album/dto/album-create.dto.ts deleted file mode 100644 index 1b4a75332e..0000000000 --- a/server/src/domain/album/dto/album-create.dto.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { ApiProperty } from '@nestjs/swagger'; -import { IsString } from 'class-validator'; -import { Optional, ValidateUUID } from 'src/validation'; - -export class CreateAlbumDto { - @IsString() - @ApiProperty() - albumName!: string; - - @IsString() - @Optional() - description?: string; - - @ValidateUUID({ optional: true, each: true }) - sharedWithUserIds?: string[]; - - @ValidateUUID({ optional: true, each: true }) - assetIds?: string[]; -} diff --git a/server/src/domain/album/dto/album-update.dto.ts b/server/src/domain/album/dto/album-update.dto.ts deleted file mode 100644 index cf2d5f8c26..0000000000 --- a/server/src/domain/album/dto/album-update.dto.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { ApiProperty } from '@nestjs/swagger'; -import { IsEnum, IsString } from 'class-validator'; -import { AssetOrder } from 'src/entities/album.entity'; -import { Optional, ValidateBoolean, ValidateUUID } from 'src/validation'; - -export class UpdateAlbumDto { - @Optional() - @IsString() - albumName?: string; - - @Optional() - @IsString() - description?: string; - - @ValidateUUID({ optional: true }) - albumThumbnailAssetId?: string; - - @ValidateBoolean({ optional: true }) - isActivityEnabled?: boolean; - - @IsEnum(AssetOrder) - @Optional() - @ApiProperty({ enum: AssetOrder, enumName: 'AssetOrder' }) - order?: AssetOrder; -} diff --git a/server/src/domain/album/dto/album.dto.ts b/server/src/domain/album/dto/album.dto.ts deleted file mode 100644 index fe0eb0d5cf..0000000000 --- a/server/src/domain/album/dto/album.dto.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { ValidateBoolean } from 'src/validation'; - -export class AlbumInfoDto { - @ValidateBoolean({ optional: true }) - withoutAssets?: boolean; -} diff --git a/server/src/domain/album/dto/get-albums.dto.ts b/server/src/domain/album/dto/get-albums.dto.ts deleted file mode 100644 index 15e4f1cf23..0000000000 --- a/server/src/domain/album/dto/get-albums.dto.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { ValidateBoolean, ValidateUUID } from 'src/validation'; - -export class GetAlbumsDto { - @ValidateBoolean({ optional: true }) - /** - * true: only shared albums - * false: only non-shared own albums - * undefined: shared and owned albums - */ - shared?: boolean; - - /** - * Only returns albums that contain the asset - * Ignores the shared parameter - * undefined: get all albums - */ - @ValidateUUID({ optional: true }) - assetId?: string; -} diff --git a/server/src/domain/api-key/api-key.service.ts b/server/src/domain/api-key/api-key.service.ts index 540c1d71f5..6c874895bc 100644 --- a/server/src/domain/api-key/api-key.service.ts +++ b/server/src/domain/api-key/api-key.service.ts @@ -1,6 +1,6 @@ import { BadRequestException, Inject, Injectable } from '@nestjs/common'; -import { APIKeyCreateDto, APIKeyCreateResponseDto, APIKeyResponseDto } from 'src/domain/api-key/api-key.dto'; -import { AuthDto } from 'src/domain/auth/auth.dto'; +import { APIKeyCreateDto, APIKeyCreateResponseDto, APIKeyResponseDto } from 'src/dtos/api-key.dto'; +import { AuthDto } from 'src/dtos/auth.dto'; import { APIKeyEntity } from 'src/entities/api-key.entity'; import { IKeyRepository } from 'src/interfaces/api-key.repository'; import { ICryptoRepository } from 'src/interfaces/crypto.repository'; diff --git a/server/src/domain/asset/asset.service.spec.ts b/server/src/domain/asset/asset.service.spec.ts index 7b49cfef96..a3603c3dac 100644 --- a/server/src/domain/asset/asset.service.spec.ts +++ b/server/src/domain/asset/asset.service.spec.ts @@ -1,10 +1,9 @@ import { BadRequestException, UnauthorizedException } from '@nestjs/common'; import { when } from 'jest-when'; -import { AssetService, UploadFieldName } from 'src/domain/asset/asset.service'; -import { AssetJobName } from 'src/domain/asset/dto/asset-ids.dto'; -import { AssetStatsResponseDto } from 'src/domain/asset/dto/asset-statistics.dto'; -import { mapAsset } from 'src/domain/asset/response-dto/asset-response.dto'; +import { AssetService } from 'src/domain/asset/asset.service'; import { JobName } from 'src/domain/job/job.constants'; +import { mapAsset } from 'src/dtos/asset-response.dto'; +import { AssetJobName, AssetStatsResponseDto, UploadFieldName } from 'src/dtos/asset.dto'; import { AssetEntity, AssetType } from 'src/entities/asset.entity'; import { IAssetStackRepository } from 'src/interfaces/asset-stack.repository'; import { AssetStats, IAssetRepository, TimeBucketSize } from 'src/interfaces/asset.repository'; diff --git a/server/src/domain/asset/asset.service.ts b/server/src/domain/asset/asset.service.ts index 38446b5763..51a587a679 100644 --- a/server/src/domain/asset/asset.service.ts +++ b/server/src/domain/asset/asset.service.ts @@ -6,25 +6,29 @@ import sanitize from 'sanitize-filename'; import { AccessCore, Permission } from 'src/cores/access.core'; import { StorageCore, StorageFolder } from 'src/cores/storage.core'; import { SystemConfigCore } from 'src/cores/system-config.core'; -import { AssetJobName, AssetJobsDto } from 'src/domain/asset/dto/asset-ids.dto'; -import { UpdateStackParentDto } from 'src/domain/asset/dto/asset-stack.dto'; -import { AssetStatsDto, mapStats } from 'src/domain/asset/dto/asset-statistics.dto'; -import { AssetBulkDeleteDto, AssetBulkUpdateDto, UpdateAssetDto } from 'src/domain/asset/dto/asset.dto'; -import { MapMarkerDto } from 'src/domain/asset/dto/map-marker.dto'; -import { MemoryLaneDto } from 'src/domain/asset/dto/memory-lane.dto'; -import { TimeBucketAssetDto, TimeBucketDto } from 'src/domain/asset/dto/time-bucket.dto'; +import { mimeTypes } from 'src/domain/domain.constant'; +import { JOBS_ASSET_PAGINATION_SIZE, JobName } from 'src/domain/job/job.constants'; +import { IAssetDeletionJob, ISidecarWriteJob } from 'src/domain/job/job.interface'; import { AssetResponseDto, MemoryLaneResponseDto, SanitizedAssetResponseDto, mapAsset, -} from 'src/domain/asset/response-dto/asset-response.dto'; -import { MapMarkerResponseDto } from 'src/domain/asset/response-dto/map-marker-response.dto'; -import { TimeBucketResponseDto } from 'src/domain/asset/response-dto/time-bucket-response.dto'; -import { AuthDto } from 'src/domain/auth/auth.dto'; -import { mimeTypes } from 'src/domain/domain.constant'; -import { JOBS_ASSET_PAGINATION_SIZE, JobName } from 'src/domain/job/job.constants'; -import { IAssetDeletionJob, ISidecarWriteJob } from 'src/domain/job/job.interface'; +} from 'src/dtos/asset-response.dto'; +import { + AssetBulkDeleteDto, + AssetBulkUpdateDto, + AssetJobName, + AssetJobsDto, + AssetStatsDto, + UpdateAssetDto, + UploadFieldName, + mapStats, +} from 'src/dtos/asset.dto'; +import { AuthDto } from 'src/dtos/auth.dto'; +import { MapMarkerDto, MapMarkerResponseDto, MemoryLaneDto } from 'src/dtos/search.dto'; +import { UpdateStackParentDto } from 'src/dtos/stack.dto'; +import { TimeBucketAssetDto, TimeBucketDto, TimeBucketResponseDto } from 'src/dtos/time-bucket.dto'; import { AssetEntity } from 'src/entities/asset.entity'; import { LibraryType } from 'src/entities/library.entity'; import { ImmichLogger } from 'src/infra/logger'; @@ -39,13 +43,6 @@ import { ISystemConfigRepository } from 'src/interfaces/system-config.repository import { IUserRepository } from 'src/interfaces/user.repository'; import { usePagination } from 'src/utils'; -export enum UploadFieldName { - ASSET_DATA = 'assetData', - LIVE_PHOTO_DATA = 'livePhotoData', - SIDECAR_DATA = 'sidecarData', - PROFILE_DATA = 'file', -} - export interface UploadRequest { auth: AuthDto | null; fieldName: UploadFieldName; diff --git a/server/src/domain/asset/dto/asset-ids.dto.ts b/server/src/domain/asset/dto/asset-ids.dto.ts deleted file mode 100644 index ea875e85e5..0000000000 --- a/server/src/domain/asset/dto/asset-ids.dto.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { ApiProperty } from '@nestjs/swagger'; -import { IsEnum } from 'class-validator'; -import { ValidateUUID } from 'src/validation'; - -export class AssetIdsDto { - @ValidateUUID({ each: true }) - assetIds!: string[]; -} - -export enum AssetJobName { - REGENERATE_THUMBNAIL = 'regenerate-thumbnail', - REFRESH_METADATA = 'refresh-metadata', - TRANSCODE_VIDEO = 'transcode-video', -} - -export class AssetJobsDto extends AssetIdsDto { - @ApiProperty({ enumName: 'AssetJobName', enum: AssetJobName }) - @IsEnum(AssetJobName) - name!: AssetJobName; -} diff --git a/server/src/domain/asset/dto/asset-statistics.dto.ts b/server/src/domain/asset/dto/asset-statistics.dto.ts deleted file mode 100644 index 93e0070293..0000000000 --- a/server/src/domain/asset/dto/asset-statistics.dto.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { ApiProperty } from '@nestjs/swagger'; -import { AssetType } from 'src/entities/asset.entity'; -import { AssetStats } from 'src/interfaces/asset.repository'; -import { ValidateBoolean } from 'src/validation'; - -export class AssetStatsDto { - @ValidateBoolean({ optional: true }) - isArchived?: boolean; - - @ValidateBoolean({ optional: true }) - isFavorite?: boolean; - - @ValidateBoolean({ optional: true }) - isTrashed?: boolean; -} - -export class AssetStatsResponseDto { - @ApiProperty({ type: 'integer' }) - images!: number; - - @ApiProperty({ type: 'integer' }) - videos!: number; - - @ApiProperty({ type: 'integer' }) - total!: number; -} - -export const mapStats = (stats: AssetStats): AssetStatsResponseDto => { - return { - images: stats[AssetType.IMAGE], - videos: stats[AssetType.VIDEO], - total: Object.values(stats).reduce((total, value) => total + value, 0), - }; -}; diff --git a/server/src/domain/asset/dto/asset.dto.ts b/server/src/domain/asset/dto/asset.dto.ts deleted file mode 100644 index a93a59ae3b..0000000000 --- a/server/src/domain/asset/dto/asset.dto.ts +++ /dev/null @@ -1,75 +0,0 @@ -import { Type } from 'class-transformer'; -import { - IsDateString, - IsInt, - IsLatitude, - IsLongitude, - IsNotEmpty, - IsPositive, - IsString, - ValidateIf, -} from 'class-validator'; -import { BulkIdsDto } from 'src/domain/asset/response-dto/asset-ids-response.dto'; -import { Optional, ValidateBoolean, ValidateUUID } from 'src/validation'; - -export class DeviceIdDto { - @IsNotEmpty() - @IsString() - deviceId!: string; -} - -const hasGPS = (o: { latitude: undefined; longitude: undefined }) => - o.latitude !== undefined || o.longitude !== undefined; -const ValidateGPS = () => ValidateIf(hasGPS); - -export class UpdateAssetBase { - @ValidateBoolean({ optional: true }) - isFavorite?: boolean; - - @ValidateBoolean({ optional: true }) - isArchived?: boolean; - - @Optional() - @IsDateString() - dateTimeOriginal?: string; - - @ValidateGPS() - @IsLatitude() - @IsNotEmpty() - latitude?: number; - - @ValidateGPS() - @IsLongitude() - @IsNotEmpty() - longitude?: number; -} - -export class AssetBulkUpdateDto extends UpdateAssetBase { - @ValidateUUID({ each: true }) - ids!: string[]; - - @ValidateUUID({ optional: true }) - stackParentId?: string; - - @ValidateBoolean({ optional: true }) - removeParent?: boolean; -} - -export class UpdateAssetDto extends UpdateAssetBase { - @Optional() - @IsString() - description?: string; -} - -export class RandomAssetsDto { - @Optional() - @IsInt() - @IsPositive() - @Type(() => Number) - count?: number; -} - -export class AssetBulkDeleteDto extends BulkIdsDto { - @ValidateBoolean({ optional: true }) - force?: boolean; -} diff --git a/server/src/domain/asset/dto/map-marker.dto.ts b/server/src/domain/asset/dto/map-marker.dto.ts deleted file mode 100644 index 158750e516..0000000000 --- a/server/src/domain/asset/dto/map-marker.dto.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { ValidateBoolean, ValidateDate } from 'src/validation'; - -export class MapMarkerDto { - @ValidateBoolean({ optional: true }) - isArchived?: boolean; - - @ValidateBoolean({ optional: true }) - isFavorite?: boolean; - - @ValidateDate({ optional: true }) - fileCreatedAfter?: Date; - - @ValidateDate({ optional: true }) - fileCreatedBefore?: Date; - - @ValidateBoolean({ optional: true }) - withPartners?: boolean; -} diff --git a/server/src/domain/asset/dto/memory-lane.dto.ts b/server/src/domain/asset/dto/memory-lane.dto.ts deleted file mode 100644 index 43f74aff1e..0000000000 --- a/server/src/domain/asset/dto/memory-lane.dto.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { ApiProperty } from '@nestjs/swagger'; -import { Type } from 'class-transformer'; -import { IsInt, Max, Min } from 'class-validator'; - -export class MemoryLaneDto { - @IsInt() - @Type(() => Number) - @Max(31) - @Min(1) - @ApiProperty({ type: 'integer' }) - day!: number; - - @IsInt() - @Type(() => Number) - @Max(12) - @Min(1) - @ApiProperty({ type: 'integer' }) - month!: number; -} diff --git a/server/src/domain/asset/response-dto/map-marker-response.dto.ts b/server/src/domain/asset/response-dto/map-marker-response.dto.ts deleted file mode 100644 index f5148883f5..0000000000 --- a/server/src/domain/asset/response-dto/map-marker-response.dto.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { ApiProperty } from '@nestjs/swagger'; - -export class MapMarkerResponseDto { - @ApiProperty() - id!: string; - - @ApiProperty({ format: 'double' }) - lat!: number; - - @ApiProperty({ format: 'double' }) - lon!: number; - - @ApiProperty() - city!: string | null; - - @ApiProperty() - state!: string | null; - - @ApiProperty() - country!: string | null; -} diff --git a/server/src/domain/asset/response-dto/smart-info-response.dto.ts b/server/src/domain/asset/response-dto/smart-info-response.dto.ts deleted file mode 100644 index c55c7ffb33..0000000000 --- a/server/src/domain/asset/response-dto/smart-info-response.dto.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { SmartInfoEntity } from 'src/entities/smart-info.entity'; - -export class SmartInfoResponseDto { - tags?: string[] | null; - objects?: string[] | null; -} - -export function mapSmartInfo(entity: SmartInfoEntity): SmartInfoResponseDto { - return { - tags: entity.tags, - objects: entity.objects, - }; -} diff --git a/server/src/domain/asset/response-dto/time-bucket-response.dto.ts b/server/src/domain/asset/response-dto/time-bucket-response.dto.ts deleted file mode 100644 index e143dde464..0000000000 --- a/server/src/domain/asset/response-dto/time-bucket-response.dto.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { ApiProperty } from '@nestjs/swagger'; - -export class TimeBucketResponseDto { - @ApiProperty({ type: 'string' }) - timeBucket!: string; - - @ApiProperty({ type: 'integer' }) - count!: number; -} diff --git a/server/src/domain/audit/audit.service.ts b/server/src/domain/audit/audit.service.ts index 91acb54d94..b84f3824df 100644 --- a/server/src/domain/audit/audit.service.ts +++ b/server/src/domain/audit/audit.service.ts @@ -3,6 +3,8 @@ import { DateTime } from 'luxon'; import { resolve } from 'node:path'; import { AccessCore, Permission } from 'src/cores/access.core'; import { StorageCore, StorageFolder } from 'src/cores/storage.core'; +import { AUDIT_LOG_MAX_DURATION } from 'src/domain/domain.constant'; +import { JOBS_ASSET_PAGINATION_SIZE } from 'src/domain/job/job.constants'; import { AuditDeletesDto, AuditDeletesResponseDto, @@ -10,10 +12,8 @@ import { FileChecksumResponseDto, FileReportItemDto, PathEntityType, -} from 'src/domain/audit/audit.dto'; -import { AuthDto } from 'src/domain/auth/auth.dto'; -import { AUDIT_LOG_MAX_DURATION } from 'src/domain/domain.constant'; -import { JOBS_ASSET_PAGINATION_SIZE } from 'src/domain/job/job.constants'; +} from 'src/dtos/audit.dto'; +import { AuthDto } from 'src/dtos/auth.dto'; import { DatabaseAction } from 'src/entities/audit.entity'; import { AssetPathType, PersonPathType, UserPathType } from 'src/entities/move.entity'; import { ImmichLogger } from 'src/infra/logger'; diff --git a/server/src/domain/auth/auth.service.spec.ts b/server/src/domain/auth/auth.service.spec.ts index e091cdcd97..37c759937f 100644 --- a/server/src/domain/auth/auth.service.spec.ts +++ b/server/src/domain/auth/auth.service.spec.ts @@ -3,8 +3,8 @@ import { IncomingHttpHeaders } from 'node:http'; import { Issuer, generators } from 'openid-client'; import { Socket } from 'socket.io'; import { AuthType } from 'src/domain/auth/auth.constant'; -import { AuthDto, SignUpDto } from 'src/domain/auth/auth.dto'; import { AuthService } from 'src/domain/auth/auth.service'; +import { AuthDto, SignUpDto } from 'src/dtos/auth.dto'; import { UserEntity } from 'src/entities/user.entity'; import { IKeyRepository } from 'src/interfaces/api-key.repository'; import { ICryptoRepository } from 'src/interfaces/crypto.repository'; diff --git a/server/src/domain/auth/auth.service.ts b/server/src/domain/auth/auth.service.ts index 2d807a249f..9ae41a4fc0 100644 --- a/server/src/domain/auth/auth.service.ts +++ b/server/src/domain/auth/auth.service.ts @@ -35,8 +35,8 @@ import { SignUpDto, mapLoginResponse, mapUserToken, -} from 'src/domain/auth/auth.dto'; -import { UserResponseDto, mapUser } from 'src/domain/user/response-dto/user-response.dto'; +} from 'src/dtos/auth.dto'; +import { UserResponseDto, mapUser } from 'src/dtos/user.dto'; import { SystemConfig } from 'src/entities/system-config.entity'; import { UserEntity } from 'src/entities/user.entity'; import { ImmichLogger } from 'src/infra/logger'; diff --git a/server/src/domain/download/download.service.spec.ts b/server/src/domain/download/download.service.spec.ts index 6e1eafbecd..cfdff82b91 100644 --- a/server/src/domain/download/download.service.spec.ts +++ b/server/src/domain/download/download.service.spec.ts @@ -1,7 +1,7 @@ import { BadRequestException } from '@nestjs/common'; import { when } from 'jest-when'; -import { DownloadResponseDto } from 'src/domain/download/download.dto'; import { DownloadService } from 'src/domain/download/download.service'; +import { DownloadResponseDto } from 'src/dtos/download.dto'; import { IAssetRepository } from 'src/interfaces/asset.repository'; import { IStorageRepository } from 'src/interfaces/storage.repository'; import { CacheControl, ImmichFileResponse } from 'src/utils'; diff --git a/server/src/domain/download/download.service.ts b/server/src/domain/download/download.service.ts index 8c0168a6cd..b03951764b 100644 --- a/server/src/domain/download/download.service.ts +++ b/server/src/domain/download/download.service.ts @@ -1,10 +1,10 @@ import { BadRequestException, Inject, Injectable } from '@nestjs/common'; import { parse } from 'node:path'; import { AccessCore, Permission } from 'src/cores/access.core'; -import { AssetIdsDto } from 'src/domain/asset/dto/asset-ids.dto'; -import { AuthDto } from 'src/domain/auth/auth.dto'; import { mimeTypes } from 'src/domain/domain.constant'; -import { DownloadArchiveInfo, DownloadInfoDto, DownloadResponseDto } from 'src/domain/download/download.dto'; +import { AssetIdsDto } from 'src/dtos/asset.dto'; +import { AuthDto } from 'src/dtos/auth.dto'; +import { DownloadArchiveInfo, DownloadInfoDto, DownloadResponseDto } from 'src/dtos/download.dto'; import { AssetEntity } from 'src/entities/asset.entity'; import { IAccessRepository } from 'src/interfaces/access.repository'; import { IAssetRepository } from 'src/interfaces/asset.repository'; diff --git a/server/src/domain/job/job.service.ts b/server/src/domain/job/job.service.ts index 192b093c1e..8650b92d46 100644 --- a/server/src/domain/job/job.service.ts +++ b/server/src/domain/job/job.service.ts @@ -1,8 +1,8 @@ import { BadRequestException, Inject, Injectable } from '@nestjs/common'; import { FeatureFlag, SystemConfigCore } from 'src/cores/system-config.core'; -import { mapAsset } from 'src/domain/asset/response-dto/asset-response.dto'; import { ConcurrentQueueName, JobCommand, JobName, QueueName } from 'src/domain/job/job.constants'; -import { AllJobStatusResponseDto, JobCommandDto, JobStatusDto } from 'src/domain/job/job.dto'; +import { mapAsset } from 'src/dtos/asset-response.dto'; +import { AllJobStatusResponseDto, JobCommandDto, JobStatusDto } from 'src/dtos/job.dto'; import { AssetType } from 'src/entities/asset.entity'; import { ImmichLogger } from 'src/infra/logger'; import { IAssetRepository } from 'src/interfaces/asset.repository'; diff --git a/server/src/domain/library/library.service.spec.ts b/server/src/domain/library/library.service.spec.ts index f34b6d5bed..81bf1cc867 100644 --- a/server/src/domain/library/library.service.spec.ts +++ b/server/src/domain/library/library.service.spec.ts @@ -5,8 +5,8 @@ import { Stats } from 'node:fs'; import { SystemConfigCore } from 'src/cores/system-config.core'; import { JobName } from 'src/domain/job/job.constants'; import { ILibraryFileJob, ILibraryRefreshJob } from 'src/domain/job/job.interface'; -import { mapLibrary } from 'src/domain/library/library.dto'; import { LibraryService } from 'src/domain/library/library.service'; +import { mapLibrary } from 'src/dtos/library.dto'; import { AssetType } from 'src/entities/asset.entity'; import { LibraryType } from 'src/entities/library.entity'; import { SystemConfig, SystemConfigKey } from 'src/entities/system-config.entity'; diff --git a/server/src/domain/library/library.service.ts b/server/src/domain/library/library.service.ts index 1fc0091493..f7b298797a 100644 --- a/server/src/domain/library/library.service.ts +++ b/server/src/domain/library/library.service.ts @@ -22,7 +22,7 @@ import { ValidateLibraryImportPathResponseDto, ValidateLibraryResponseDto, mapLibrary, -} from 'src/domain/library/library.dto'; +} from 'src/dtos/library.dto'; import { AssetType } from 'src/entities/asset.entity'; import { LibraryEntity, LibraryType } from 'src/entities/library.entity'; import { ImmichLogger } from 'src/infra/logger'; diff --git a/server/src/domain/media/media.service.ts b/server/src/domain/media/media.service.ts index c254689b4e..5c217f2a80 100644 --- a/server/src/domain/media/media.service.ts +++ b/server/src/domain/media/media.service.ts @@ -13,7 +13,7 @@ import { VAAPIConfig, VP9Config, } from 'src/domain/media/media.util'; -import { SystemConfigFFmpegDto } from 'src/domain/system-config/dto/system-config-ffmpeg.dto'; +import { SystemConfigFFmpegDto } from 'src/dtos/system-config-ffmpeg.dto'; import { AssetEntity, AssetType } from 'src/entities/asset.entity'; import { AssetPathType } from 'src/entities/move.entity'; import { diff --git a/server/src/domain/media/media.util.ts b/server/src/domain/media/media.util.ts index 3e58ca81ac..d6a5b53a68 100644 --- a/server/src/domain/media/media.util.ts +++ b/server/src/domain/media/media.util.ts @@ -1,4 +1,4 @@ -import { SystemConfigFFmpegDto } from 'src/domain/system-config/dto/system-config-ffmpeg.dto'; +import { SystemConfigFFmpegDto } from 'src/dtos/system-config-ffmpeg.dto'; import { CQMode, ToneMapping, TranscodeHWAccel, TranscodeTarget, VideoCodec } from 'src/entities/system-config.entity'; import { AudioStreamInfo, diff --git a/server/src/domain/partner/partner.service.spec.ts b/server/src/domain/partner/partner.service.spec.ts index 7d48212823..1256a9ca04 100644 --- a/server/src/domain/partner/partner.service.spec.ts +++ b/server/src/domain/partner/partner.service.spec.ts @@ -1,6 +1,6 @@ import { BadRequestException } from '@nestjs/common'; -import { PartnerResponseDto } from 'src/domain/partner/partner.dto'; import { PartnerService } from 'src/domain/partner/partner.service'; +import { PartnerResponseDto } from 'src/dtos/partner.dto'; import { UserAvatarColor } from 'src/entities/user.entity'; import { IAccessRepository } from 'src/interfaces/access.repository'; import { IPartnerRepository, PartnerDirection } from 'src/interfaces/partner.repository'; diff --git a/server/src/domain/partner/partner.service.ts b/server/src/domain/partner/partner.service.ts index 34a88a7ea9..af3f98061b 100644 --- a/server/src/domain/partner/partner.service.ts +++ b/server/src/domain/partner/partner.service.ts @@ -1,8 +1,8 @@ import { BadRequestException, Inject, Injectable } from '@nestjs/common'; import { AccessCore, Permission } from 'src/cores/access.core'; -import { AuthDto } from 'src/domain/auth/auth.dto'; -import { PartnerResponseDto, UpdatePartnerDto } from 'src/domain/partner/partner.dto'; -import { mapUser } from 'src/domain/user/response-dto/user-response.dto'; +import { AuthDto } from 'src/dtos/auth.dto'; +import { PartnerResponseDto, UpdatePartnerDto } from 'src/dtos/partner.dto'; +import { mapUser } from 'src/dtos/user.dto'; import { PartnerEntity } from 'src/entities/partner.entity'; import { IAccessRepository } from 'src/interfaces/access.repository'; import { IPartnerRepository, PartnerDirection, PartnerIds } from 'src/interfaces/partner.repository'; diff --git a/server/src/domain/person/person.service.spec.ts b/server/src/domain/person/person.service.spec.ts index 9da66e8686..3f555e34f1 100644 --- a/server/src/domain/person/person.service.spec.ts +++ b/server/src/domain/person/person.service.spec.ts @@ -1,8 +1,8 @@ import { BadRequestException, NotFoundException } from '@nestjs/common'; -import { BulkIdErrorReason } from 'src/domain/asset/response-dto/asset-ids-response.dto'; import { JobName } from 'src/domain/job/job.constants'; -import { PersonResponseDto, mapFaces, mapPerson } from 'src/domain/person/person.dto'; import { PersonService } from 'src/domain/person/person.service'; +import { BulkIdErrorReason } from 'src/dtos/asset-ids.response.dto'; +import { PersonResponseDto, mapFaces, mapPerson } from 'src/dtos/person.dto'; import { AssetFaceEntity } from 'src/entities/asset-face.entity'; import { Colorspace, SystemConfigKey } from 'src/entities/system-config.entity'; import { IAssetRepository, WithoutProperty } from 'src/interfaces/asset.repository'; diff --git a/server/src/domain/person/person.service.ts b/server/src/domain/person/person.service.ts index cd7ba92246..7da482966f 100644 --- a/server/src/domain/person/person.service.ts +++ b/server/src/domain/person/person.service.ts @@ -2,13 +2,13 @@ import { BadRequestException, Inject, Injectable, NotFoundException } from '@nes import { AccessCore, Permission } from 'src/cores/access.core'; import { StorageCore } from 'src/cores/storage.core'; import { SystemConfigCore } from 'src/cores/system-config.core'; -import { BulkIdErrorReason, BulkIdResponseDto } from 'src/domain/asset/response-dto/asset-ids-response.dto'; -import { AssetResponseDto, mapAsset } from 'src/domain/asset/response-dto/asset-response.dto'; -import { AuthDto } from 'src/domain/auth/auth.dto'; import { mimeTypes } from 'src/domain/domain.constant'; import { JOBS_ASSET_PAGINATION_SIZE, JobName, QueueName } from 'src/domain/job/job.constants'; import { IBaseJob, IDeferrableJob, IEntityJob } from 'src/domain/job/job.interface'; import { FACE_THUMBNAIL_SIZE } from 'src/domain/media/media.constant'; +import { BulkIdErrorReason, BulkIdResponseDto } from 'src/dtos/asset-ids.response.dto'; +import { AssetResponseDto, mapAsset } from 'src/dtos/asset-response.dto'; +import { AuthDto } from 'src/dtos/auth.dto'; import { AssetFaceResponseDto, AssetFaceUpdateDto, @@ -23,7 +23,7 @@ import { PersonUpdateDto, mapFaces, mapPerson, -} from 'src/domain/person/person.dto'; +} from 'src/dtos/person.dto'; import { PersonPathType } from 'src/entities/move.entity'; import { PersonEntity } from 'src/entities/person.entity'; import { ImmichLogger } from 'src/infra/logger'; diff --git a/server/src/domain/search/dto/search-suggestion.dto.ts b/server/src/domain/search/dto/search-suggestion.dto.ts deleted file mode 100644 index f702293d0c..0000000000 --- a/server/src/domain/search/dto/search-suggestion.dto.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { ApiProperty } from '@nestjs/swagger'; -import { IsEnum, IsNotEmpty, IsString } from 'class-validator'; -import { Optional } from 'src/validation'; - -export enum SearchSuggestionType { - COUNTRY = 'country', - STATE = 'state', - CITY = 'city', - CAMERA_MAKE = 'camera-make', - CAMERA_MODEL = 'camera-model', -} - -export class SearchSuggestionRequestDto { - @IsEnum(SearchSuggestionType) - @IsNotEmpty() - @ApiProperty({ enumName: 'SearchSuggestionType', enum: SearchSuggestionType }) - type!: SearchSuggestionType; - - @IsString() - @Optional() - country?: string; - - @IsString() - @Optional() - state?: string; - - @IsString() - @Optional() - make?: string; - - @IsString() - @Optional() - model?: string; -} diff --git a/server/src/domain/search/response-dto/search-explore.response.dto.ts b/server/src/domain/search/response-dto/search-explore.response.dto.ts deleted file mode 100644 index 33689b9797..0000000000 --- a/server/src/domain/search/response-dto/search-explore.response.dto.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { AssetResponseDto } from 'src/domain/asset/response-dto/asset-response.dto'; - -class SearchExploreItem { - value!: string; - data!: AssetResponseDto; -} - -export class SearchExploreResponseDto { - fieldName!: string; - items!: SearchExploreItem[]; -} diff --git a/server/src/domain/search/response-dto/search-response.dto.ts b/server/src/domain/search/response-dto/search-response.dto.ts deleted file mode 100644 index 53563a9ac8..0000000000 --- a/server/src/domain/search/response-dto/search-response.dto.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { ApiProperty } from '@nestjs/swagger'; -import { AlbumResponseDto } from 'src/domain/album/album-response.dto'; -import { AssetResponseDto } from 'src/domain/asset/response-dto/asset-response.dto'; - -class SearchFacetCountResponseDto { - @ApiProperty({ type: 'integer' }) - count!: number; - value!: string; -} - -class SearchFacetResponseDto { - fieldName!: string; - counts!: SearchFacetCountResponseDto[]; -} - -class SearchAlbumResponseDto { - @ApiProperty({ type: 'integer' }) - total!: number; - @ApiProperty({ type: 'integer' }) - count!: number; - items!: AlbumResponseDto[]; - facets!: SearchFacetResponseDto[]; -} - -class SearchAssetResponseDto { - @ApiProperty({ type: 'integer' }) - total!: number; - @ApiProperty({ type: 'integer' }) - count!: number; - items!: AssetResponseDto[]; - facets!: SearchFacetResponseDto[]; - nextPage!: string | null; -} - -export class SearchResponseDto { - albums!: SearchAlbumResponseDto; - assets!: SearchAssetResponseDto; -} diff --git a/server/src/domain/search/search.service.spec.ts b/server/src/domain/search/search.service.spec.ts index f722128098..7f83f2ff09 100644 --- a/server/src/domain/search/search.service.spec.ts +++ b/server/src/domain/search/search.service.spec.ts @@ -1,6 +1,6 @@ -import { mapAsset } from 'src/domain/asset/response-dto/asset-response.dto'; -import { SearchDto } from 'src/domain/search/dto/search.dto'; import { SearchService } from 'src/domain/search/search.service'; +import { mapAsset } from 'src/dtos/asset-response.dto'; +import { SearchDto } from 'src/dtos/search.dto'; import { SystemConfigKey } from 'src/entities/system-config.entity'; import { IAssetRepository } from 'src/interfaces/asset.repository'; import { IMachineLearningRepository } from 'src/interfaces/machine-learning.repository'; diff --git a/server/src/domain/search/search.service.ts b/server/src/domain/search/search.service.ts index cedee68d05..30819dc460 100644 --- a/server/src/domain/search/search.service.ts +++ b/server/src/domain/search/search.service.ts @@ -1,19 +1,20 @@ import { Inject, Injectable } from '@nestjs/common'; import { FeatureFlag, SystemConfigCore } from 'src/cores/system-config.core'; -import { AssetResponseDto, mapAsset } from 'src/domain/asset/response-dto/asset-response.dto'; -import { AuthDto } from 'src/domain/auth/auth.dto'; -import { PersonResponseDto } from 'src/domain/person/person.dto'; -import { SearchSuggestionRequestDto, SearchSuggestionType } from 'src/domain/search/dto/search-suggestion.dto'; +import { AssetResponseDto, mapAsset } from 'src/dtos/asset-response.dto'; +import { AuthDto } from 'src/dtos/auth.dto'; +import { PersonResponseDto } from 'src/dtos/person.dto'; import { MetadataSearchDto, PlacesResponseDto, SearchDto, SearchPeopleDto, SearchPlacesDto, + SearchResponseDto, + SearchSuggestionRequestDto, + SearchSuggestionType, SmartSearchDto, mapPlaces, -} from 'src/domain/search/dto/search.dto'; -import { SearchResponseDto } from 'src/domain/search/response-dto/search-response.dto'; +} from 'src/dtos/search.dto'; import { AssetOrder } from 'src/entities/album.entity'; import { AssetEntity } from 'src/entities/asset.entity'; import { IAssetRepository } from 'src/interfaces/asset.repository'; diff --git a/server/src/domain/server-info/server-info.service.ts b/server/src/domain/server-info/server-info.service.ts index 13921949cf..a76ae4022b 100644 --- a/server/src/domain/server-info/server-info.service.ts +++ b/server/src/domain/server-info/server-info.service.ts @@ -11,7 +11,7 @@ import { ServerPingResponse, ServerStatsResponseDto, UsageByUserDto, -} from 'src/domain/server-info/server-info.dto'; +} from 'src/dtos/server-info.dto'; import { SystemMetadataKey } from 'src/entities/system-metadata.entity'; import { ImmichLogger } from 'src/infra/logger'; import { ClientEvent, ICommunicationRepository } from 'src/interfaces/communication.repository'; diff --git a/server/src/domain/shared-link/shared-link.dto.ts b/server/src/domain/shared-link/shared-link.dto.ts deleted file mode 100644 index 73928aac23..0000000000 --- a/server/src/domain/shared-link/shared-link.dto.ts +++ /dev/null @@ -1,75 +0,0 @@ -import { ApiProperty } from '@nestjs/swagger'; -import { IsEnum, IsString } from 'class-validator'; -import { SharedLinkType } from 'src/entities/shared-link.entity'; -import { Optional, ValidateBoolean, ValidateDate, ValidateUUID } from 'src/validation'; - -export class SharedLinkCreateDto { - @IsEnum(SharedLinkType) - @ApiProperty({ enum: SharedLinkType, enumName: 'SharedLinkType' }) - type!: SharedLinkType; - - @ValidateUUID({ each: true, optional: true }) - assetIds?: string[]; - - @ValidateUUID({ optional: true }) - albumId?: string; - - @IsString() - @Optional() - description?: string; - - @IsString() - @Optional() - password?: string; - - @ValidateDate({ optional: true, nullable: true }) - expiresAt?: Date | null = null; - - @ValidateBoolean({ optional: true }) - allowUpload?: boolean; - - @ValidateBoolean({ optional: true }) - allowDownload?: boolean = true; - - @ValidateBoolean({ optional: true }) - showMetadata?: boolean = true; -} - -export class SharedLinkEditDto { - @Optional() - description?: string; - - @Optional() - password?: string; - - @Optional({ nullable: true }) - expiresAt?: Date | null; - - @Optional() - allowUpload?: boolean; - - @ValidateBoolean({ optional: true }) - allowDownload?: boolean; - - @ValidateBoolean({ optional: true }) - showMetadata?: boolean; - - /** - * Few clients cannot send null to set the expiryTime to never. - * Setting this flag and not sending expiryAt is considered as null instead. - * Clients that can send null values can ignore this. - */ - @ValidateBoolean({ optional: true }) - changeExpiryTime?: boolean; -} - -export class SharedLinkPasswordDto { - @IsString() - @Optional() - @ApiProperty({ example: 'password' }) - password?: string; - - @IsString() - @Optional() - token?: string; -} diff --git a/server/src/domain/shared-link/shared-link.service.spec.ts b/server/src/domain/shared-link/shared-link.service.spec.ts index 926ec16b13..e5e3ea6e2e 100644 --- a/server/src/domain/shared-link/shared-link.service.spec.ts +++ b/server/src/domain/shared-link/shared-link.service.spec.ts @@ -1,7 +1,7 @@ import { BadRequestException, ForbiddenException, UnauthorizedException } from '@nestjs/common'; import _ from 'lodash'; -import { AssetIdErrorReason } from 'src/domain/asset/response-dto/asset-ids-response.dto'; import { SharedLinkService } from 'src/domain/shared-link/shared-link.service'; +import { AssetIdErrorReason } from 'src/dtos/asset-ids.response.dto'; import { SharedLinkType } from 'src/entities/shared-link.entity'; import { ICryptoRepository } from 'src/interfaces/crypto.repository'; import { ISharedLinkRepository } from 'src/interfaces/shared-link.repository'; diff --git a/server/src/domain/shared-link/shared-link.service.ts b/server/src/domain/shared-link/shared-link.service.ts index e01deee7b9..a84a1f1206 100644 --- a/server/src/domain/shared-link/shared-link.service.ts +++ b/server/src/domain/shared-link/shared-link.service.ts @@ -1,14 +1,16 @@ import { BadRequestException, ForbiddenException, Inject, Injectable, UnauthorizedException } from '@nestjs/common'; import { AccessCore, Permission } from 'src/cores/access.core'; -import { AssetIdsDto } from 'src/domain/asset/dto/asset-ids.dto'; -import { AssetIdErrorReason, AssetIdsResponseDto } from 'src/domain/asset/response-dto/asset-ids-response.dto'; -import { AuthDto } from 'src/domain/auth/auth.dto'; +import { AssetIdErrorReason, AssetIdsResponseDto } from 'src/dtos/asset-ids.response.dto'; +import { AssetIdsDto } from 'src/dtos/asset.dto'; +import { AuthDto } from 'src/dtos/auth.dto'; import { + SharedLinkCreateDto, + SharedLinkEditDto, + SharedLinkPasswordDto, SharedLinkResponseDto, mapSharedLink, mapSharedLinkWithoutMetadata, -} from 'src/domain/shared-link/shared-link-response.dto'; -import { SharedLinkCreateDto, SharedLinkEditDto, SharedLinkPasswordDto } from 'src/domain/shared-link/shared-link.dto'; +} from 'src/dtos/shared-link.dto'; import { AssetEntity } from 'src/entities/asset.entity'; import { SharedLinkEntity, SharedLinkType } from 'src/entities/shared-link.entity'; import { IAccessRepository } from 'src/interfaces/access.repository'; diff --git a/server/src/domain/system-config/response-dto/system-config-template-storage-option.dto.ts b/server/src/domain/system-config/response-dto/system-config-template-storage-option.dto.ts deleted file mode 100644 index f0c8b9b64a..0000000000 --- a/server/src/domain/system-config/response-dto/system-config-template-storage-option.dto.ts +++ /dev/null @@ -1,10 +0,0 @@ -export class SystemConfigTemplateStorageOptionDto { - yearOptions!: string[]; - monthOptions!: string[]; - weekOptions!: string[]; - dayOptions!: string[]; - hourOptions!: string[]; - minuteOptions!: string[]; - secondOptions!: string[]; - presetOptions!: string[]; -} diff --git a/server/src/domain/system-config/system-config.service.ts b/server/src/domain/system-config/system-config.service.ts index d69593d217..c5837dca27 100644 --- a/server/src/domain/system-config/system-config.service.ts +++ b/server/src/domain/system-config/system-config.service.ts @@ -3,8 +3,6 @@ import { OnEvent } from '@nestjs/event-emitter'; import { instanceToPlain } from 'class-transformer'; import _ from 'lodash'; import { SystemConfigCore } from 'src/cores/system-config.core'; -import { SystemConfigDto, mapConfig } from 'src/domain/system-config/dto/system-config.dto'; -import { SystemConfigTemplateStorageOptionDto } from 'src/domain/system-config/response-dto/system-config-template-storage-option.dto'; import { supportedDayTokens, supportedHourTokens, @@ -15,6 +13,8 @@ import { supportedWeekTokens, supportedYearTokens, } from 'src/domain/system-config/system-config.constants'; +import { SystemConfigTemplateStorageOptionDto } from 'src/dtos/system-config-storage-template.dto'; +import { SystemConfigDto, mapConfig } from 'src/dtos/system-config.dto'; import { LogLevel, SystemConfig } from 'src/entities/system-config.entity'; import { ImmichLogger } from 'src/infra/logger'; import { diff --git a/server/src/domain/tag/tag.dto.ts b/server/src/domain/tag/tag.dto.ts deleted file mode 100644 index abf9549d81..0000000000 --- a/server/src/domain/tag/tag.dto.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { ApiProperty } from '@nestjs/swagger'; -import { IsEnum, IsNotEmpty, IsString } from 'class-validator'; -import { TagType } from 'src/entities/tag.entity'; -import { Optional } from 'src/validation'; - -export class CreateTagDto { - @IsString() - @IsNotEmpty() - name!: string; - - @IsEnum(TagType) - @IsNotEmpty() - @ApiProperty({ enumName: 'TagTypeEnum', enum: TagType }) - type!: TagType; -} - -export class UpdateTagDto { - @IsString() - @Optional() - name?: string; -} diff --git a/server/src/domain/tag/tag.service.spec.ts b/server/src/domain/tag/tag.service.spec.ts index 9f630cdc0c..c7aeba9f1d 100644 --- a/server/src/domain/tag/tag.service.spec.ts +++ b/server/src/domain/tag/tag.service.spec.ts @@ -1,7 +1,7 @@ import { BadRequestException } from '@nestjs/common'; import { when } from 'jest-when'; -import { AssetIdErrorReason } from 'src/domain/asset/response-dto/asset-ids-response.dto'; import { TagService } from 'src/domain/tag/tag.service'; +import { AssetIdErrorReason } from 'src/dtos/asset-ids.response.dto'; import { TagType } from 'src/entities/tag.entity'; import { ITagRepository } from 'src/interfaces/tag.repository'; import { assetStub } from 'test/fixtures/asset.stub'; diff --git a/server/src/domain/tag/tag.service.ts b/server/src/domain/tag/tag.service.ts index b04e251f7c..b53eac0d70 100644 --- a/server/src/domain/tag/tag.service.ts +++ b/server/src/domain/tag/tag.service.ts @@ -1,10 +1,9 @@ import { BadRequestException, Inject, Injectable } from '@nestjs/common'; -import { AssetIdsDto } from 'src/domain/asset/dto/asset-ids.dto'; -import { AssetIdErrorReason, AssetIdsResponseDto } from 'src/domain/asset/response-dto/asset-ids-response.dto'; -import { AssetResponseDto, mapAsset } from 'src/domain/asset/response-dto/asset-response.dto'; -import { AuthDto } from 'src/domain/auth/auth.dto'; -import { TagResponseDto, mapTag } from 'src/domain/tag/tag-response.dto'; -import { CreateTagDto, UpdateTagDto } from 'src/domain/tag/tag.dto'; +import { AssetIdErrorReason, AssetIdsResponseDto } from 'src/dtos/asset-ids.response.dto'; +import { AssetResponseDto, mapAsset } from 'src/dtos/asset-response.dto'; +import { AssetIdsDto } from 'src/dtos/asset.dto'; +import { AuthDto } from 'src/dtos/auth.dto'; +import { CreateTagDto, TagResponseDto, UpdateTagDto, mapTag } from 'src/dtos/tag.dto'; import { ITagRepository } from 'src/interfaces/tag.repository'; @Injectable() diff --git a/server/src/domain/trash/trash.service.ts b/server/src/domain/trash/trash.service.ts index 2043b42481..9bece663b8 100644 --- a/server/src/domain/trash/trash.service.ts +++ b/server/src/domain/trash/trash.service.ts @@ -1,9 +1,9 @@ import { Inject } from '@nestjs/common'; import { DateTime } from 'luxon'; import { AccessCore, Permission } from 'src/cores/access.core'; -import { BulkIdsDto } from 'src/domain/asset/response-dto/asset-ids-response.dto'; -import { AuthDto } from 'src/domain/auth/auth.dto'; import { JOBS_ASSET_PAGINATION_SIZE, JobName } from 'src/domain/job/job.constants'; +import { BulkIdsDto } from 'src/dtos/asset-ids.response.dto'; +import { AuthDto } from 'src/dtos/auth.dto'; import { IAccessRepository } from 'src/interfaces/access.repository'; import { IAssetRepository } from 'src/interfaces/asset.repository'; import { ClientEvent, ICommunicationRepository } from 'src/interfaces/communication.repository'; diff --git a/server/src/domain/user/dto/create-profile-image.dto.ts b/server/src/domain/user/dto/create-profile-image.dto.ts deleted file mode 100644 index 37a7d13409..0000000000 --- a/server/src/domain/user/dto/create-profile-image.dto.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { ApiProperty } from '@nestjs/swagger'; -import { UploadFieldName } from 'src/domain/asset/asset.service'; - -export class CreateProfileImageDto { - @ApiProperty({ type: 'string', format: 'binary' }) - [UploadFieldName.PROFILE_DATA]!: Express.Multer.File; -} diff --git a/server/src/domain/user/dto/create-user.dto.ts b/server/src/domain/user/dto/create-user.dto.ts deleted file mode 100644 index 7861c58c25..0000000000 --- a/server/src/domain/user/dto/create-user.dto.ts +++ /dev/null @@ -1,61 +0,0 @@ -import { ApiProperty } from '@nestjs/swagger'; -import { Transform } from 'class-transformer'; -import { IsEmail, IsNotEmpty, IsNumber, IsPositive, IsString } from 'class-validator'; -import { Optional, ValidateBoolean, toEmail, toSanitized } from 'src/validation'; - -export class CreateUserDto { - @IsEmail({ require_tld: false }) - @Transform(toEmail) - email!: string; - - @IsNotEmpty() - @IsString() - password!: string; - - @IsNotEmpty() - @IsString() - name!: string; - - @Optional({ nullable: true }) - @IsString() - @Transform(toSanitized) - storageLabel?: string | null; - - @ValidateBoolean({ optional: true }) - memoriesEnabled?: boolean; - - @Optional({ nullable: true }) - @IsNumber() - @IsPositive() - @ApiProperty({ type: 'integer', format: 'int64' }) - quotaSizeInBytes?: number | null; - - @ValidateBoolean({ optional: true }) - shouldChangePassword?: boolean; -} - -export class CreateAdminDto { - @IsNotEmpty() - isAdmin!: true; - - @IsEmail({ require_tld: false }) - @Transform(({ value }) => value?.toLowerCase()) - email!: string; - - @IsNotEmpty() - password!: string; - - @IsNotEmpty() - name!: string; -} - -export class CreateUserOAuthDto { - @IsEmail({ require_tld: false }) - @Transform(({ value }) => value?.toLowerCase()) - email!: string; - - @IsNotEmpty() - oauthId!: string; - - name?: string; -} diff --git a/server/src/domain/user/dto/delete-user.dto.ts b/server/src/domain/user/dto/delete-user.dto.ts deleted file mode 100644 index aa41e18aad..0000000000 --- a/server/src/domain/user/dto/delete-user.dto.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { ValidateBoolean } from 'src/validation'; - -export class DeleteUserDto { - @ValidateBoolean({ optional: true }) - force?: boolean; -} diff --git a/server/src/domain/user/dto/update-user.dto.spec.ts b/server/src/domain/user/dto/update-user.dto.spec.ts deleted file mode 100644 index 0ad407be31..0000000000 --- a/server/src/domain/user/dto/update-user.dto.spec.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { plainToInstance } from 'class-transformer'; -import { validate } from 'class-validator'; -import { UpdateUserDto } from 'src/domain/user/dto/update-user.dto'; - -describe('update user DTO', () => { - it('should allow emails without a tld', async () => { - const someEmail = 'test@test'; - - const dto = plainToInstance(UpdateUserDto, { - email: someEmail, - id: '3fe388e4-2078-44d7-b36c-39d9dee3a657', - }); - const errors = await validate(dto); - expect(errors).toHaveLength(0); - expect(dto.email).toEqual(someEmail); - }); -}); diff --git a/server/src/domain/user/dto/update-user.dto.ts b/server/src/domain/user/dto/update-user.dto.ts deleted file mode 100644 index 059971e6c6..0000000000 --- a/server/src/domain/user/dto/update-user.dto.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { ApiProperty } from '@nestjs/swagger'; -import { Transform } from 'class-transformer'; -import { IsEmail, IsEnum, IsNotEmpty, IsNumber, IsPositive, IsString, IsUUID } from 'class-validator'; -import { UserAvatarColor } from 'src/entities/user.entity'; -import { Optional, ValidateBoolean, toEmail, toSanitized } from 'src/validation'; - -export class UpdateUserDto { - @Optional() - @IsEmail({ require_tld: false }) - @Transform(toEmail) - email?: string; - - @Optional() - @IsNotEmpty() - @IsString() - password?: string; - - @Optional() - @IsString() - @IsNotEmpty() - name?: string; - - @Optional() - @IsString() - @Transform(toSanitized) - storageLabel?: string; - - @IsNotEmpty() - @IsUUID('4') - @ApiProperty({ format: 'uuid' }) - id!: string; - - @ValidateBoolean({ optional: true }) - isAdmin?: boolean; - - @ValidateBoolean({ optional: true }) - shouldChangePassword?: boolean; - - @ValidateBoolean({ optional: true }) - memoriesEnabled?: boolean; - - @Optional() - @IsEnum(UserAvatarColor) - @ApiProperty({ enumName: 'UserAvatarColor', enum: UserAvatarColor }) - avatarColor?: UserAvatarColor; - - @Optional({ nullable: true }) - @IsNumber() - @IsPositive() - @ApiProperty({ type: 'integer', format: 'int64' }) - quotaSizeInBytes?: number | null; -} diff --git a/server/src/domain/user/response-dto/create-profile-image-response.dto.ts b/server/src/domain/user/response-dto/create-profile-image-response.dto.ts deleted file mode 100644 index 2c7fd17be7..0000000000 --- a/server/src/domain/user/response-dto/create-profile-image-response.dto.ts +++ /dev/null @@ -1,11 +0,0 @@ -export class CreateProfileImageResponseDto { - userId!: string; - profileImagePath!: string; -} - -export function mapCreateProfileImageResponse(userId: string, profileImagePath: string): CreateProfileImageResponseDto { - return { - userId: userId, - profileImagePath: profileImagePath, - }; -} diff --git a/server/src/domain/user/response-dto/user-response.dto.ts b/server/src/domain/user/response-dto/user-response.dto.ts deleted file mode 100644 index 12ffca48c2..0000000000 --- a/server/src/domain/user/response-dto/user-response.dto.ts +++ /dev/null @@ -1,65 +0,0 @@ -import { ApiProperty } from '@nestjs/swagger'; -import { IsEnum } from 'class-validator'; -import { UserAvatarColor, UserEntity, UserStatus } from 'src/entities/user.entity'; - -export const getRandomAvatarColor = (user: UserEntity): UserAvatarColor => { - const values = Object.values(UserAvatarColor); - const randomIndex = Math.floor( - [...user.email].map((letter) => letter.codePointAt(0) ?? 0).reduce((a, b) => a + b, 0) % values.length, - ); - return values[randomIndex] as UserAvatarColor; -}; - -export class UserDto { - id!: string; - name!: string; - email!: string; - profileImagePath!: string; - @IsEnum(UserAvatarColor) - @ApiProperty({ enumName: 'UserAvatarColor', enum: UserAvatarColor }) - avatarColor!: UserAvatarColor; -} - -export class UserResponseDto extends UserDto { - storageLabel!: string | null; - shouldChangePassword!: boolean; - isAdmin!: boolean; - createdAt!: Date; - deletedAt!: Date | null; - updatedAt!: Date; - oauthId!: string; - memoriesEnabled?: boolean; - @ApiProperty({ type: 'integer', format: 'int64' }) - quotaSizeInBytes!: number | null; - @ApiProperty({ type: 'integer', format: 'int64' }) - quotaUsageInBytes!: number | null; - @ApiProperty({ enumName: 'UserStatus', enum: UserStatus }) - status!: string; -} - -export const mapSimpleUser = (entity: UserEntity): UserDto => { - return { - id: entity.id, - email: entity.email, - name: entity.name, - profileImagePath: entity.profileImagePath, - avatarColor: entity.avatarColor ?? getRandomAvatarColor(entity), - }; -}; - -export function mapUser(entity: UserEntity): UserResponseDto { - return { - ...mapSimpleUser(entity), - storageLabel: entity.storageLabel, - shouldChangePassword: entity.shouldChangePassword, - isAdmin: entity.isAdmin, - createdAt: entity.createdAt, - deletedAt: entity.deletedAt, - updatedAt: entity.updatedAt, - oauthId: entity.oauthId, - memoriesEnabled: entity.memoriesEnabled, - quotaSizeInBytes: entity.quotaSizeInBytes, - quotaUsageInBytes: entity.quotaUsageInBytes, - status: entity.status, - }; -} diff --git a/server/src/domain/user/user.service.spec.ts b/server/src/domain/user/user.service.spec.ts index 5b9a1de957..804a892c7d 100644 --- a/server/src/domain/user/user.service.spec.ts +++ b/server/src/domain/user/user.service.spec.ts @@ -6,9 +6,8 @@ import { } from '@nestjs/common'; import { when } from 'jest-when'; import { JobName } from 'src/domain/job/job.constants'; -import { UpdateUserDto } from 'src/domain/user/dto/update-user.dto'; -import { mapUser } from 'src/domain/user/response-dto/user-response.dto'; import { UserService } from 'src/domain/user/user.service'; +import { UpdateUserDto, mapUser } from 'src/dtos/user.dto'; import { UserEntity, UserStatus } from 'src/entities/user.entity'; import { IAlbumRepository } from 'src/interfaces/album.repository'; import { ICryptoRepository } from 'src/interfaces/crypto.repository'; diff --git a/server/src/domain/user/user.service.ts b/server/src/domain/user/user.service.ts index 349a775ec5..ef742123ff 100644 --- a/server/src/domain/user/user.service.ts +++ b/server/src/domain/user/user.service.ts @@ -4,17 +4,11 @@ import { randomBytes } from 'node:crypto'; import { StorageCore, StorageFolder } from 'src/cores/storage.core'; import { SystemConfigCore } from 'src/cores/system-config.core'; import { UserCore } from 'src/cores/user.core'; -import { AuthDto } from 'src/domain/auth/auth.dto'; import { JobName } from 'src/domain/job/job.constants'; import { IEntityJob } from 'src/domain/job/job.interface'; -import { CreateUserDto } from 'src/domain/user/dto/create-user.dto'; -import { DeleteUserDto } from 'src/domain/user/dto/delete-user.dto'; -import { UpdateUserDto } from 'src/domain/user/dto/update-user.dto'; -import { - CreateProfileImageResponseDto, - mapCreateProfileImageResponse, -} from 'src/domain/user/response-dto/create-profile-image-response.dto'; -import { UserResponseDto, mapUser } from 'src/domain/user/response-dto/user-response.dto'; +import { AuthDto } from 'src/dtos/auth.dto'; +import { CreateProfileImageResponseDto, mapCreateProfileImageResponse } from 'src/dtos/user-profile.dto'; +import { CreateUserDto, DeleteUserDto, UpdateUserDto, UserResponseDto, mapUser } from 'src/dtos/user.dto'; import { UserEntity, UserStatus } from 'src/entities/user.entity'; import { ImmichLogger } from 'src/infra/logger'; import { IAlbumRepository } from 'src/interfaces/album.repository'; diff --git a/server/src/domain/activity/activity.dto.ts b/server/src/dtos/activity.dto.ts similarity index 95% rename from server/src/domain/activity/activity.dto.ts rename to server/src/dtos/activity.dto.ts index a9d8657783..bd0d400951 100644 --- a/server/src/domain/activity/activity.dto.ts +++ b/server/src/dtos/activity.dto.ts @@ -1,6 +1,6 @@ import { ApiProperty } from '@nestjs/swagger'; import { IsEnum, IsNotEmpty, IsString, ValidateIf } from 'class-validator'; -import { UserDto, mapSimpleUser } from 'src/domain/user/response-dto/user-response.dto'; +import { UserDto, mapSimpleUser } from 'src/dtos/user.dto'; import { ActivityEntity } from 'src/entities/activity.entity'; import { Optional, ValidateUUID } from 'src/validation'; diff --git a/server/src/domain/album/album-response.dto.spec.ts b/server/src/dtos/album-response.dto.spec.ts similarity index 89% rename from server/src/domain/album/album-response.dto.spec.ts rename to server/src/dtos/album-response.dto.spec.ts index 568b416b4d..2a6d59abf3 100644 --- a/server/src/domain/album/album-response.dto.spec.ts +++ b/server/src/dtos/album-response.dto.spec.ts @@ -1,4 +1,4 @@ -import { mapAlbum } from 'src/domain/album/album-response.dto'; +import { mapAlbum } from 'src/dtos/album.dto'; import { albumStub } from 'test/fixtures/album.stub'; describe('mapAlbum', () => { diff --git a/server/src/domain/album/album-response.dto.ts b/server/src/dtos/album.dto.ts similarity index 59% rename from server/src/domain/album/album-response.dto.ts rename to server/src/dtos/album.dto.ts index b016a1200b..3f7af0f538 100644 --- a/server/src/domain/album/album-response.dto.ts +++ b/server/src/dtos/album.dto.ts @@ -1,9 +1,87 @@ import { ApiProperty } from '@nestjs/swagger'; -import { AssetResponseDto, mapAsset } from 'src/domain/asset/response-dto/asset-response.dto'; -import { AuthDto } from 'src/domain/auth/auth.dto'; -import { UserResponseDto, mapUser } from 'src/domain/user/response-dto/user-response.dto'; +import { ArrayNotEmpty, IsEnum, IsString } from 'class-validator'; +import { AssetResponseDto, mapAsset } from 'src/dtos/asset-response.dto'; +import { AuthDto } from 'src/dtos/auth.dto'; +import { UserResponseDto, mapUser } from 'src/dtos/user.dto'; import { AlbumEntity, AssetOrder } from 'src/entities/album.entity'; -import { Optional } from 'src/validation'; +import { Optional, ValidateBoolean, ValidateUUID } from 'src/validation'; + +export class AlbumInfoDto { + @ValidateBoolean({ optional: true }) + withoutAssets?: boolean; +} + +export class AddUsersDto { + @ValidateUUID({ each: true }) + @ArrayNotEmpty() + sharedUserIds!: string[]; +} + +export class CreateAlbumDto { + @IsString() + @ApiProperty() + albumName!: string; + + @IsString() + @Optional() + description?: string; + + @ValidateUUID({ optional: true, each: true }) + sharedWithUserIds?: string[]; + + @ValidateUUID({ optional: true, each: true }) + assetIds?: string[]; +} + +export class UpdateAlbumDto { + @Optional() + @IsString() + albumName?: string; + + @Optional() + @IsString() + description?: string; + + @ValidateUUID({ optional: true }) + albumThumbnailAssetId?: string; + + @ValidateBoolean({ optional: true }) + isActivityEnabled?: boolean; + + @IsEnum(AssetOrder) + @Optional() + @ApiProperty({ enum: AssetOrder, enumName: 'AssetOrder' }) + order?: AssetOrder; +} + +export class GetAlbumsDto { + @ValidateBoolean({ optional: true }) + /** + * true: only shared albums + * false: only non-shared own albums + * undefined: shared and owned albums + */ + shared?: boolean; + + /** + * Only returns albums that contain the asset + * Ignores the shared parameter + * undefined: get all albums + */ + @ValidateUUID({ optional: true }) + assetId?: string; +} + +export class AlbumCountResponseDto { + @ApiProperty({ type: 'integer' }) + owned!: number; + + @ApiProperty({ type: 'integer' }) + shared!: number; + + @ApiProperty({ type: 'integer' }) + notShared!: number; +} export class AlbumResponseDto { id!: string; @@ -73,14 +151,3 @@ export const mapAlbum = (entity: AlbumEntity, withAssets: boolean, auth?: AuthDt export const mapAlbumWithAssets = (entity: AlbumEntity) => mapAlbum(entity, true); export const mapAlbumWithoutAssets = (entity: AlbumEntity) => mapAlbum(entity, false); - -export class AlbumCountResponseDto { - @ApiProperty({ type: 'integer' }) - owned!: number; - - @ApiProperty({ type: 'integer' }) - shared!: number; - - @ApiProperty({ type: 'integer' }) - notShared!: number; -} diff --git a/server/src/domain/api-key/api-key.dto.ts b/server/src/dtos/api-key.dto.ts similarity index 100% rename from server/src/domain/api-key/api-key.dto.ts rename to server/src/dtos/api-key.dto.ts diff --git a/server/src/domain/asset/response-dto/asset-ids-response.dto.ts b/server/src/dtos/asset-ids.response.dto.ts similarity index 100% rename from server/src/domain/asset/response-dto/asset-ids-response.dto.ts rename to server/src/dtos/asset-ids.response.dto.ts diff --git a/server/src/domain/asset/response-dto/asset-response.dto.ts b/server/src/dtos/asset-response.dto.ts similarity index 88% rename from server/src/domain/asset/response-dto/asset-response.dto.ts rename to server/src/dtos/asset-response.dto.ts index dff12d481b..04e36645e1 100644 --- a/server/src/domain/asset/response-dto/asset-response.dto.ts +++ b/server/src/dtos/asset-response.dto.ts @@ -1,12 +1,12 @@ import { ApiProperty } from '@nestjs/swagger'; -import { ExifResponseDto, mapExif } from 'src/domain/asset/response-dto/exif-response.dto'; -import { SmartInfoResponseDto, mapSmartInfo } from 'src/domain/asset/response-dto/smart-info-response.dto'; -import { AuthDto } from 'src/domain/auth/auth.dto'; -import { PersonWithFacesResponseDto, mapFacesWithoutPerson, mapPerson } from 'src/domain/person/person.dto'; -import { TagResponseDto, mapTag } from 'src/domain/tag/tag-response.dto'; -import { UserResponseDto, mapUser } from 'src/domain/user/response-dto/user-response.dto'; +import { AuthDto } from 'src/dtos/auth.dto'; +import { ExifResponseDto, mapExif } from 'src/dtos/exif.dto'; +import { PersonWithFacesResponseDto, mapFacesWithoutPerson, mapPerson } from 'src/dtos/person.dto'; +import { TagResponseDto, mapTag } from 'src/dtos/tag.dto'; +import { UserResponseDto, mapUser } from 'src/dtos/user.dto'; import { AssetFaceEntity } from 'src/entities/asset-face.entity'; import { AssetEntity, AssetType } from 'src/entities/asset.entity'; +import { SmartInfoEntity } from 'src/entities/smart-info.entity'; export class SanitizedAssetResponseDto { id!: string; @@ -134,3 +134,15 @@ export class MemoryLaneResponseDto { title!: string; assets!: AssetResponseDto[]; } + +export class SmartInfoResponseDto { + tags?: string[] | null; + objects?: string[] | null; +} + +export function mapSmartInfo(entity: SmartInfoEntity): SmartInfoResponseDto { + return { + tags: entity.tags, + objects: entity.objects, + }; +} diff --git a/server/src/dtos/asset.dto.ts b/server/src/dtos/asset.dto.ts new file mode 100644 index 0000000000..5ccf63c987 --- /dev/null +++ b/server/src/dtos/asset.dto.ts @@ -0,0 +1,132 @@ +import { ApiProperty } from '@nestjs/swagger'; +import { Type } from 'class-transformer'; +import { + IsDateString, + IsEnum, + IsInt, + IsLatitude, + IsLongitude, + IsNotEmpty, + IsPositive, + IsString, + ValidateIf, +} from 'class-validator'; +import { BulkIdsDto } from 'src/dtos/asset-ids.response.dto'; +import { AssetType } from 'src/entities/asset.entity'; +import { AssetStats } from 'src/interfaces/asset.repository'; +import { Optional, ValidateBoolean, ValidateUUID } from 'src/validation'; + +export class DeviceIdDto { + @IsNotEmpty() + @IsString() + deviceId!: string; +} + +const hasGPS = (o: { latitude: undefined; longitude: undefined }) => + o.latitude !== undefined || o.longitude !== undefined; +const ValidateGPS = () => ValidateIf(hasGPS); + +export class UpdateAssetBase { + @ValidateBoolean({ optional: true }) + isFavorite?: boolean; + + @ValidateBoolean({ optional: true }) + isArchived?: boolean; + + @Optional() + @IsDateString() + dateTimeOriginal?: string; + + @ValidateGPS() + @IsLatitude() + @IsNotEmpty() + latitude?: number; + + @ValidateGPS() + @IsLongitude() + @IsNotEmpty() + longitude?: number; +} + +export class AssetBulkUpdateDto extends UpdateAssetBase { + @ValidateUUID({ each: true }) + ids!: string[]; + + @ValidateUUID({ optional: true }) + stackParentId?: string; + + @ValidateBoolean({ optional: true }) + removeParent?: boolean; +} + +export class UpdateAssetDto extends UpdateAssetBase { + @Optional() + @IsString() + description?: string; +} + +export class RandomAssetsDto { + @Optional() + @IsInt() + @IsPositive() + @Type(() => Number) + count?: number; +} + +export class AssetBulkDeleteDto extends BulkIdsDto { + @ValidateBoolean({ optional: true }) + force?: boolean; +} + +export class AssetIdsDto { + @ValidateUUID({ each: true }) + assetIds!: string[]; +} + +export enum AssetJobName { + REGENERATE_THUMBNAIL = 'regenerate-thumbnail', + REFRESH_METADATA = 'refresh-metadata', + TRANSCODE_VIDEO = 'transcode-video', +} + +export class AssetJobsDto extends AssetIdsDto { + @ApiProperty({ enumName: 'AssetJobName', enum: AssetJobName }) + @IsEnum(AssetJobName) + name!: AssetJobName; +} + +export class AssetStatsDto { + @ValidateBoolean({ optional: true }) + isArchived?: boolean; + + @ValidateBoolean({ optional: true }) + isFavorite?: boolean; + + @ValidateBoolean({ optional: true }) + isTrashed?: boolean; +} + +export class AssetStatsResponseDto { + @ApiProperty({ type: 'integer' }) + images!: number; + + @ApiProperty({ type: 'integer' }) + videos!: number; + + @ApiProperty({ type: 'integer' }) + total!: number; +} + +export const mapStats = (stats: AssetStats): AssetStatsResponseDto => { + return { + images: stats[AssetType.IMAGE], + videos: stats[AssetType.VIDEO], + total: Object.values(stats).reduce((total, value) => total + value, 0), + }; +}; +export enum UploadFieldName { + ASSET_DATA = 'assetData', + LIVE_PHOTO_DATA = 'livePhotoData', + SIDECAR_DATA = 'sidecarData', + PROFILE_DATA = 'file', +} diff --git a/server/src/domain/audit/audit.dto.ts b/server/src/dtos/audit.dto.ts similarity index 100% rename from server/src/domain/audit/audit.dto.ts rename to server/src/dtos/audit.dto.ts diff --git a/server/src/domain/auth/auth.dto.ts b/server/src/dtos/auth.dto.ts similarity index 100% rename from server/src/domain/auth/auth.dto.ts rename to server/src/dtos/auth.dto.ts diff --git a/server/src/domain/download/download.dto.ts b/server/src/dtos/download.dto.ts similarity index 100% rename from server/src/domain/download/download.dto.ts rename to server/src/dtos/download.dto.ts diff --git a/server/src/domain/asset/response-dto/exif-response.dto.ts b/server/src/dtos/exif.dto.ts similarity index 100% rename from server/src/domain/asset/response-dto/exif-response.dto.ts rename to server/src/dtos/exif.dto.ts diff --git a/server/src/domain/job/job.dto.ts b/server/src/dtos/job.dto.ts similarity index 100% rename from server/src/domain/job/job.dto.ts rename to server/src/dtos/job.dto.ts diff --git a/server/src/domain/library/library.dto.ts b/server/src/dtos/library.dto.ts similarity index 100% rename from server/src/domain/library/library.dto.ts rename to server/src/dtos/library.dto.ts diff --git a/server/src/domain/smart-info/dto/model-config.dto.ts b/server/src/dtos/model-config.dto.ts similarity index 100% rename from server/src/domain/smart-info/dto/model-config.dto.ts rename to server/src/dtos/model-config.dto.ts diff --git a/server/src/domain/partner/partner.dto.ts b/server/src/dtos/partner.dto.ts similarity index 71% rename from server/src/domain/partner/partner.dto.ts rename to server/src/dtos/partner.dto.ts index c197d20797..187f8f341b 100644 --- a/server/src/domain/partner/partner.dto.ts +++ b/server/src/dtos/partner.dto.ts @@ -1,5 +1,5 @@ import { IsNotEmpty } from 'class-validator'; -import { UserResponseDto } from 'src/domain/user/response-dto/user-response.dto'; +import { UserResponseDto } from 'src/dtos/user.dto'; export class UpdatePartnerDto { @IsNotEmpty() diff --git a/server/src/domain/person/person.dto.ts b/server/src/dtos/person.dto.ts similarity index 98% rename from server/src/domain/person/person.dto.ts rename to server/src/dtos/person.dto.ts index 4153ba8132..b28f18603a 100644 --- a/server/src/domain/person/person.dto.ts +++ b/server/src/dtos/person.dto.ts @@ -1,7 +1,7 @@ import { ApiProperty } from '@nestjs/swagger'; import { Type } from 'class-transformer'; import { IsArray, IsNotEmpty, IsString, MaxDate, ValidateNested } from 'class-validator'; -import { AuthDto } from 'src/domain/auth/auth.dto'; +import { AuthDto } from 'src/dtos/auth.dto'; import { AssetFaceEntity } from 'src/entities/asset-face.entity'; import { PersonEntity } from 'src/entities/person.entity'; import { Optional, ValidateBoolean, ValidateDate, ValidateUUID } from 'src/validation'; diff --git a/server/src/domain/search/dto/search.dto.ts b/server/src/dtos/search.dto.ts similarity index 66% rename from server/src/domain/search/dto/search.dto.ts rename to server/src/dtos/search.dto.ts index 4f77517b3b..799baddee3 100644 --- a/server/src/domain/search/dto/search.dto.ts +++ b/server/src/dtos/search.dto.ts @@ -1,6 +1,8 @@ import { ApiProperty } from '@nestjs/swagger'; import { Type } from 'class-transformer'; import { IsEnum, IsInt, IsNotEmpty, IsString, Max, Min } from 'class-validator'; +import { AlbumResponseDto } from 'src/dtos/album.dto'; +import { AssetResponseDto } from 'src/dtos/asset-response.dto'; import { AssetOrder } from 'src/entities/album.entity'; import { AssetType } from 'src/entities/asset.entity'; import { GeodataPlacesEntity } from 'src/entities/geodata-places.entity'; @@ -264,3 +266,130 @@ export function mapPlaces(place: GeodataPlacesEntity): PlacesResponseDto { admin2name: place.admin2Name, }; } +export enum SearchSuggestionType { + COUNTRY = 'country', + STATE = 'state', + CITY = 'city', + CAMERA_MAKE = 'camera-make', + CAMERA_MODEL = 'camera-model', +} + +export class SearchSuggestionRequestDto { + @IsEnum(SearchSuggestionType) + @IsNotEmpty() + @ApiProperty({ enumName: 'SearchSuggestionType', enum: SearchSuggestionType }) + type!: SearchSuggestionType; + + @IsString() + @Optional() + country?: string; + + @IsString() + @Optional() + state?: string; + + @IsString() + @Optional() + make?: string; + + @IsString() + @Optional() + model?: string; +} + +class SearchFacetCountResponseDto { + @ApiProperty({ type: 'integer' }) + count!: number; + value!: string; +} + +class SearchFacetResponseDto { + fieldName!: string; + counts!: SearchFacetCountResponseDto[]; +} + +class SearchAlbumResponseDto { + @ApiProperty({ type: 'integer' }) + total!: number; + @ApiProperty({ type: 'integer' }) + count!: number; + items!: AlbumResponseDto[]; + facets!: SearchFacetResponseDto[]; +} + +class SearchAssetResponseDto { + @ApiProperty({ type: 'integer' }) + total!: number; + @ApiProperty({ type: 'integer' }) + count!: number; + items!: AssetResponseDto[]; + facets!: SearchFacetResponseDto[]; + nextPage!: string | null; +} + +export class SearchResponseDto { + albums!: SearchAlbumResponseDto; + assets!: SearchAssetResponseDto; +} + +class SearchExploreItem { + value!: string; + data!: AssetResponseDto; +} + +export class SearchExploreResponseDto { + fieldName!: string; + items!: SearchExploreItem[]; +} + +export class MapMarkerDto { + @ValidateBoolean({ optional: true }) + isArchived?: boolean; + + @ValidateBoolean({ optional: true }) + isFavorite?: boolean; + + @ValidateDate({ optional: true }) + fileCreatedAfter?: Date; + + @ValidateDate({ optional: true }) + fileCreatedBefore?: Date; + + @ValidateBoolean({ optional: true }) + withPartners?: boolean; +} + +export class MemoryLaneDto { + @IsInt() + @Type(() => Number) + @Max(31) + @Min(1) + @ApiProperty({ type: 'integer' }) + day!: number; + + @IsInt() + @Type(() => Number) + @Max(12) + @Min(1) + @ApiProperty({ type: 'integer' }) + month!: number; +} +export class MapMarkerResponseDto { + @ApiProperty() + id!: string; + + @ApiProperty({ format: 'double' }) + lat!: number; + + @ApiProperty({ format: 'double' }) + lon!: number; + + @ApiProperty() + city!: string | null; + + @ApiProperty() + state!: string | null; + + @ApiProperty() + country!: string | null; +} diff --git a/server/src/domain/server-info/server-info.dto.ts b/server/src/dtos/server-info.dto.ts similarity index 96% rename from server/src/domain/server-info/server-info.dto.ts rename to server/src/dtos/server-info.dto.ts index 0cbfbe773d..33fe830441 100644 --- a/server/src/domain/server-info/server-info.dto.ts +++ b/server/src/dtos/server-info.dto.ts @@ -2,7 +2,7 @@ import { ApiProperty, ApiResponseProperty } from '@nestjs/swagger'; import type { DateTime } from 'luxon'; import { FeatureFlags } from 'src/cores/system-config.core'; import { IVersion, VersionType } from 'src/domain/domain.constant'; -import { SystemConfigThemeDto } from 'src/domain/system-config/dto/system-config-theme.dto'; +import { SystemConfigThemeDto } from 'src/dtos/system-config-theme.dto'; export class ServerPingResponse { @ApiResponseProperty({ type: String, example: 'pong' }) diff --git a/server/src/domain/shared-link/shared-link-response.dto.ts b/server/src/dtos/shared-link.dto.ts similarity index 57% rename from server/src/domain/shared-link/shared-link-response.dto.ts rename to server/src/dtos/shared-link.dto.ts index 44024506f5..9a90901d27 100644 --- a/server/src/domain/shared-link/shared-link-response.dto.ts +++ b/server/src/dtos/shared-link.dto.ts @@ -1,9 +1,81 @@ import { ApiProperty } from '@nestjs/swagger'; +import { IsEnum, IsString } from 'class-validator'; import _ from 'lodash'; -import { AlbumResponseDto, mapAlbumWithoutAssets } from 'src/domain/album/album-response.dto'; -import { AssetResponseDto, mapAsset } from 'src/domain/asset/response-dto/asset-response.dto'; +import { AlbumResponseDto, mapAlbumWithoutAssets } from 'src/dtos/album.dto'; +import { AssetResponseDto, mapAsset } from 'src/dtos/asset-response.dto'; import { SharedLinkEntity, SharedLinkType } from 'src/entities/shared-link.entity'; +import { Optional, ValidateBoolean, ValidateDate, ValidateUUID } from 'src/validation'; +export class SharedLinkCreateDto { + @IsEnum(SharedLinkType) + @ApiProperty({ enum: SharedLinkType, enumName: 'SharedLinkType' }) + type!: SharedLinkType; + + @ValidateUUID({ each: true, optional: true }) + assetIds?: string[]; + + @ValidateUUID({ optional: true }) + albumId?: string; + + @IsString() + @Optional() + description?: string; + + @IsString() + @Optional() + password?: string; + + @ValidateDate({ optional: true, nullable: true }) + expiresAt?: Date | null = null; + + @ValidateBoolean({ optional: true }) + allowUpload?: boolean; + + @ValidateBoolean({ optional: true }) + allowDownload?: boolean = true; + + @ValidateBoolean({ optional: true }) + showMetadata?: boolean = true; +} + +export class SharedLinkEditDto { + @Optional() + description?: string; + + @Optional() + password?: string; + + @Optional({ nullable: true }) + expiresAt?: Date | null; + + @Optional() + allowUpload?: boolean; + + @ValidateBoolean({ optional: true }) + allowDownload?: boolean; + + @ValidateBoolean({ optional: true }) + showMetadata?: boolean; + + /** + * Few clients cannot send null to set the expiryTime to never. + * Setting this flag and not sending expiryAt is considered as null instead. + * Clients that can send null values can ignore this. + */ + @ValidateBoolean({ optional: true }) + changeExpiryTime?: boolean; +} + +export class SharedLinkPasswordDto { + @IsString() + @Optional() + @ApiProperty({ example: 'password' }) + password?: string; + + @IsString() + @Optional() + token?: string; +} export class SharedLinkResponseDto { id!: string; description!: string | null; diff --git a/server/src/domain/asset/dto/asset-stack.dto.ts b/server/src/dtos/stack.dto.ts similarity index 100% rename from server/src/domain/asset/dto/asset-stack.dto.ts rename to server/src/dtos/stack.dto.ts diff --git a/server/src/domain/system-config/dto/system-config-ffmpeg.dto.ts b/server/src/dtos/system-config-ffmpeg.dto.ts similarity index 100% rename from server/src/domain/system-config/dto/system-config-ffmpeg.dto.ts rename to server/src/dtos/system-config-ffmpeg.dto.ts diff --git a/server/src/domain/system-config/dto/system-config-job.dto.ts b/server/src/dtos/system-config-job.dto.ts similarity index 100% rename from server/src/domain/system-config/dto/system-config-job.dto.ts rename to server/src/dtos/system-config-job.dto.ts diff --git a/server/src/domain/system-config/dto/system-config-library.dto.ts b/server/src/dtos/system-config-library.dto.ts similarity index 100% rename from server/src/domain/system-config/dto/system-config-library.dto.ts rename to server/src/dtos/system-config-library.dto.ts diff --git a/server/src/domain/system-config/dto/system-config-logging.dto.ts b/server/src/dtos/system-config-logging.dto.ts similarity index 100% rename from server/src/domain/system-config/dto/system-config-logging.dto.ts rename to server/src/dtos/system-config-logging.dto.ts diff --git a/server/src/domain/system-config/dto/system-config-machine-learning.dto.ts b/server/src/dtos/system-config-machine-learning.dto.ts similarity index 85% rename from server/src/domain/system-config/dto/system-config-machine-learning.dto.ts rename to server/src/dtos/system-config-machine-learning.dto.ts index 0585859920..7abc9ac88c 100644 --- a/server/src/domain/system-config/dto/system-config-machine-learning.dto.ts +++ b/server/src/dtos/system-config-machine-learning.dto.ts @@ -1,6 +1,6 @@ import { Type } from 'class-transformer'; import { IsObject, IsUrl, ValidateIf, ValidateNested } from 'class-validator'; -import { CLIPConfig, RecognitionConfig } from 'src/domain/smart-info/dto/model-config.dto'; +import { CLIPConfig, RecognitionConfig } from 'src/dtos/model-config.dto'; import { ValidateBoolean } from 'src/validation'; export class SystemConfigMachineLearningDto { diff --git a/server/src/domain/system-config/dto/system-config-map.dto.ts b/server/src/dtos/system-config-map.dto.ts similarity index 100% rename from server/src/domain/system-config/dto/system-config-map.dto.ts rename to server/src/dtos/system-config-map.dto.ts diff --git a/server/src/domain/system-config/dto/system-config-new-version-check.dto.ts b/server/src/dtos/system-config-new-version-check.dto.ts similarity index 100% rename from server/src/domain/system-config/dto/system-config-new-version-check.dto.ts rename to server/src/dtos/system-config-new-version-check.dto.ts diff --git a/server/src/domain/system-config/dto/system-config-oauth.dto.ts b/server/src/dtos/system-config-oauth.dto.ts similarity index 100% rename from server/src/domain/system-config/dto/system-config-oauth.dto.ts rename to server/src/dtos/system-config-oauth.dto.ts diff --git a/server/src/domain/system-config/dto/system-config-password-login.dto.ts b/server/src/dtos/system-config-password-login.dto.ts similarity index 100% rename from server/src/domain/system-config/dto/system-config-password-login.dto.ts rename to server/src/dtos/system-config-password-login.dto.ts diff --git a/server/src/domain/system-config/dto/system-config-reverse-geocoding.dto.ts b/server/src/dtos/system-config-reverse-geocoding.dto.ts similarity index 100% rename from server/src/domain/system-config/dto/system-config-reverse-geocoding.dto.ts rename to server/src/dtos/system-config-reverse-geocoding.dto.ts diff --git a/server/src/domain/system-config/dto/system-config-server.dto.ts b/server/src/dtos/system-config-server.dto.ts similarity index 100% rename from server/src/domain/system-config/dto/system-config-server.dto.ts rename to server/src/dtos/system-config-server.dto.ts diff --git a/server/src/domain/system-config/dto/system-config-storage-template.dto.ts b/server/src/dtos/system-config-storage-template.dto.ts similarity index 53% rename from server/src/domain/system-config/dto/system-config-storage-template.dto.ts rename to server/src/dtos/system-config-storage-template.dto.ts index 77204b46e8..d56cfedb80 100644 --- a/server/src/domain/system-config/dto/system-config-storage-template.dto.ts +++ b/server/src/dtos/system-config-storage-template.dto.ts @@ -12,3 +12,14 @@ export class SystemConfigStorageTemplateDto { @IsString() template!: string; } + +export class SystemConfigTemplateStorageOptionDto { + yearOptions!: string[]; + monthOptions!: string[]; + weekOptions!: string[]; + dayOptions!: string[]; + hourOptions!: string[]; + minuteOptions!: string[]; + secondOptions!: string[]; + presetOptions!: string[]; +} diff --git a/server/src/domain/system-config/dto/system-config-theme.dto.ts b/server/src/dtos/system-config-theme.dto.ts similarity index 100% rename from server/src/domain/system-config/dto/system-config-theme.dto.ts rename to server/src/dtos/system-config-theme.dto.ts diff --git a/server/src/domain/system-config/dto/system-config-thumbnail.dto.ts b/server/src/dtos/system-config-thumbnail.dto.ts similarity index 100% rename from server/src/domain/system-config/dto/system-config-thumbnail.dto.ts rename to server/src/dtos/system-config-thumbnail.dto.ts diff --git a/server/src/domain/system-config/dto/system-config-trash.dto.ts b/server/src/dtos/system-config-trash.dto.ts similarity index 100% rename from server/src/domain/system-config/dto/system-config-trash.dto.ts rename to server/src/dtos/system-config-trash.dto.ts diff --git a/server/src/domain/system-config/dto/system-config-user.dto.ts b/server/src/dtos/system-config-user.dto.ts similarity index 100% rename from server/src/domain/system-config/dto/system-config-user.dto.ts rename to server/src/dtos/system-config-user.dto.ts diff --git a/server/src/domain/system-config/dto/system-config.dto.ts b/server/src/dtos/system-config.dto.ts similarity index 56% rename from server/src/domain/system-config/dto/system-config.dto.ts rename to server/src/dtos/system-config.dto.ts index 9aef923038..7c32376293 100644 --- a/server/src/domain/system-config/dto/system-config.dto.ts +++ b/server/src/dtos/system-config.dto.ts @@ -1,21 +1,21 @@ import { Type } from 'class-transformer'; import { IsObject, ValidateNested } from 'class-validator'; -import { SystemConfigFFmpegDto } from 'src/domain/system-config/dto/system-config-ffmpeg.dto'; -import { SystemConfigJobDto } from 'src/domain/system-config/dto/system-config-job.dto'; -import { SystemConfigLibraryDto } from 'src/domain/system-config/dto/system-config-library.dto'; -import { SystemConfigLoggingDto } from 'src/domain/system-config/dto/system-config-logging.dto'; -import { SystemConfigMachineLearningDto } from 'src/domain/system-config/dto/system-config-machine-learning.dto'; -import { SystemConfigMapDto } from 'src/domain/system-config/dto/system-config-map.dto'; -import { SystemConfigNewVersionCheckDto } from 'src/domain/system-config/dto/system-config-new-version-check.dto'; -import { SystemConfigOAuthDto } from 'src/domain/system-config/dto/system-config-oauth.dto'; -import { SystemConfigPasswordLoginDto } from 'src/domain/system-config/dto/system-config-password-login.dto'; -import { SystemConfigReverseGeocodingDto } from 'src/domain/system-config/dto/system-config-reverse-geocoding.dto'; -import { SystemConfigServerDto } from 'src/domain/system-config/dto/system-config-server.dto'; -import { SystemConfigStorageTemplateDto } from 'src/domain/system-config/dto/system-config-storage-template.dto'; -import { SystemConfigThemeDto } from 'src/domain/system-config/dto/system-config-theme.dto'; -import { SystemConfigThumbnailDto } from 'src/domain/system-config/dto/system-config-thumbnail.dto'; -import { SystemConfigTrashDto } from 'src/domain/system-config/dto/system-config-trash.dto'; -import { SystemConfigUserDto } from 'src/domain/system-config/dto/system-config-user.dto'; +import { SystemConfigFFmpegDto } from 'src/dtos/system-config-ffmpeg.dto'; +import { SystemConfigJobDto } from 'src/dtos/system-config-job.dto'; +import { SystemConfigLibraryDto } from 'src/dtos/system-config-library.dto'; +import { SystemConfigLoggingDto } from 'src/dtos/system-config-logging.dto'; +import { SystemConfigMachineLearningDto } from 'src/dtos/system-config-machine-learning.dto'; +import { SystemConfigMapDto } from 'src/dtos/system-config-map.dto'; +import { SystemConfigNewVersionCheckDto } from 'src/dtos/system-config-new-version-check.dto'; +import { SystemConfigOAuthDto } from 'src/dtos/system-config-oauth.dto'; +import { SystemConfigPasswordLoginDto } from 'src/dtos/system-config-password-login.dto'; +import { SystemConfigReverseGeocodingDto } from 'src/dtos/system-config-reverse-geocoding.dto'; +import { SystemConfigServerDto } from 'src/dtos/system-config-server.dto'; +import { SystemConfigStorageTemplateDto } from 'src/dtos/system-config-storage-template.dto'; +import { SystemConfigThemeDto } from 'src/dtos/system-config-theme.dto'; +import { SystemConfigThumbnailDto } from 'src/dtos/system-config-thumbnail.dto'; +import { SystemConfigTrashDto } from 'src/dtos/system-config-trash.dto'; +import { SystemConfigUserDto } from 'src/dtos/system-config-user.dto'; import { SystemConfig } from 'src/entities/system-config.entity'; export class SystemConfigDto implements SystemConfig { diff --git a/server/src/domain/tag/tag-response.dto.ts b/server/src/dtos/tag.dto.ts similarity index 54% rename from server/src/domain/tag/tag-response.dto.ts rename to server/src/dtos/tag.dto.ts index 535efcf434..1094d70df3 100644 --- a/server/src/domain/tag/tag-response.dto.ts +++ b/server/src/dtos/tag.dto.ts @@ -1,5 +1,24 @@ import { ApiProperty } from '@nestjs/swagger'; +import { IsEnum, IsNotEmpty, IsString } from 'class-validator'; import { TagEntity, TagType } from 'src/entities/tag.entity'; +import { Optional } from 'src/validation'; + +export class CreateTagDto { + @IsString() + @IsNotEmpty() + name!: string; + + @IsEnum(TagType) + @IsNotEmpty() + @ApiProperty({ enumName: 'TagTypeEnum', enum: TagType }) + type!: TagType; +} + +export class UpdateTagDto { + @IsString() + @Optional() + name?: string; +} export class TagResponseDto { id!: string; diff --git a/server/src/domain/asset/dto/time-bucket.dto.ts b/server/src/dtos/time-bucket.dto.ts similarity index 88% rename from server/src/domain/asset/dto/time-bucket.dto.ts rename to server/src/dtos/time-bucket.dto.ts index a5ff023d1d..40dbb84e6d 100644 --- a/server/src/domain/asset/dto/time-bucket.dto.ts +++ b/server/src/dtos/time-bucket.dto.ts @@ -44,3 +44,11 @@ export class TimeBucketAssetDto extends TimeBucketDto { @IsString() timeBucket!: string; } + +export class TimeBucketResponseDto { + @ApiProperty({ type: 'string' }) + timeBucket!: string; + + @ApiProperty({ type: 'integer' }) + count!: number; +} diff --git a/server/src/dtos/user-profile.dto.ts b/server/src/dtos/user-profile.dto.ts new file mode 100644 index 0000000000..2f3d8cf224 --- /dev/null +++ b/server/src/dtos/user-profile.dto.ts @@ -0,0 +1,28 @@ +import { ApiProperty } from '@nestjs/swagger'; +import { UploadFieldName } from 'src/dtos/asset.dto'; +import { UserAvatarColor, UserEntity } from 'src/entities/user.entity'; + +export class CreateProfileImageDto { + @ApiProperty({ type: 'string', format: 'binary' }) + [UploadFieldName.PROFILE_DATA]!: Express.Multer.File; +} + +export class CreateProfileImageResponseDto { + userId!: string; + profileImagePath!: string; +} + +export function mapCreateProfileImageResponse(userId: string, profileImagePath: string): CreateProfileImageResponseDto { + return { + userId: userId, + profileImagePath: profileImagePath, + }; +} + +export const getRandomAvatarColor = (user: UserEntity): UserAvatarColor => { + const values = Object.values(UserAvatarColor); + const randomIndex = Math.floor( + [...user.email].map((letter) => letter.codePointAt(0) ?? 0).reduce((a, b) => a + b, 0) % values.length, + ); + return values[randomIndex] as UserAvatarColor; +}; diff --git a/server/src/domain/user/dto/create-user.dto.spec.ts b/server/src/dtos/user.dto.spec.ts similarity index 79% rename from server/src/domain/user/dto/create-user.dto.spec.ts rename to server/src/dtos/user.dto.spec.ts index 28abc44ad2..d07399f0ef 100644 --- a/server/src/domain/user/dto/create-user.dto.spec.ts +++ b/server/src/dtos/user.dto.spec.ts @@ -1,6 +1,20 @@ import { plainToInstance } from 'class-transformer'; import { validate } from 'class-validator'; -import { CreateAdminDto, CreateUserDto, CreateUserOAuthDto } from 'src/domain/user/dto/create-user.dto'; +import { CreateAdminDto, CreateUserDto, CreateUserOAuthDto, UpdateUserDto } from 'src/dtos/user.dto'; + +describe('update user DTO', () => { + it('should allow emails without a tld', async () => { + const someEmail = 'test@test'; + + const dto = plainToInstance(UpdateUserDto, { + email: someEmail, + id: '3fe388e4-2078-44d7-b36c-39d9dee3a657', + }); + const errors = await validate(dto); + expect(errors).toHaveLength(0); + expect(dto.email).toEqual(someEmail); + }); +}); describe('create user DTO', () => { it('validates the email', async () => { diff --git a/server/src/dtos/user.dto.ts b/server/src/dtos/user.dto.ts new file mode 100644 index 0000000000..309006822f --- /dev/null +++ b/server/src/dtos/user.dto.ts @@ -0,0 +1,169 @@ +import { ApiProperty } from '@nestjs/swagger'; +import { Transform } from 'class-transformer'; +import { IsEmail, IsEnum, IsNotEmpty, IsNumber, IsPositive, IsString, IsUUID } from 'class-validator'; +import { getRandomAvatarColor } from 'src/dtos/user-profile.dto'; +import { UserAvatarColor, UserEntity, UserStatus } from 'src/entities/user.entity'; +import { Optional, ValidateBoolean, toEmail, toSanitized } from 'src/validation'; + +export class CreateUserDto { + @IsEmail({ require_tld: false }) + @Transform(toEmail) + email!: string; + + @IsNotEmpty() + @IsString() + password!: string; + + @IsNotEmpty() + @IsString() + name!: string; + + @Optional({ nullable: true }) + @IsString() + @Transform(toSanitized) + storageLabel?: string | null; + + @ValidateBoolean({ optional: true }) + memoriesEnabled?: boolean; + + @Optional({ nullable: true }) + @IsNumber() + @IsPositive() + @ApiProperty({ type: 'integer', format: 'int64' }) + quotaSizeInBytes?: number | null; + + @ValidateBoolean({ optional: true }) + shouldChangePassword?: boolean; +} + +export class CreateAdminDto { + @IsNotEmpty() + isAdmin!: true; + + @IsEmail({ require_tld: false }) + @Transform(({ value }) => value?.toLowerCase()) + email!: string; + + @IsNotEmpty() + password!: string; + + @IsNotEmpty() + name!: string; +} + +export class CreateUserOAuthDto { + @IsEmail({ require_tld: false }) + @Transform(({ value }) => value?.toLowerCase()) + email!: string; + + @IsNotEmpty() + oauthId!: string; + + name?: string; +} + +export class DeleteUserDto { + @ValidateBoolean({ optional: true }) + force?: boolean; +} + +export class UpdateUserDto { + @Optional() + @IsEmail({ require_tld: false }) + @Transform(toEmail) + email?: string; + + @Optional() + @IsNotEmpty() + @IsString() + password?: string; + + @Optional() + @IsString() + @IsNotEmpty() + name?: string; + + @Optional() + @IsString() + @Transform(toSanitized) + storageLabel?: string; + + @IsNotEmpty() + @IsUUID('4') + @ApiProperty({ format: 'uuid' }) + id!: string; + + @ValidateBoolean({ optional: true }) + isAdmin?: boolean; + + @ValidateBoolean({ optional: true }) + shouldChangePassword?: boolean; + + @ValidateBoolean({ optional: true }) + memoriesEnabled?: boolean; + + @Optional() + @IsEnum(UserAvatarColor) + @ApiProperty({ enumName: 'UserAvatarColor', enum: UserAvatarColor }) + avatarColor?: UserAvatarColor; + + @Optional({ nullable: true }) + @IsNumber() + @IsPositive() + @ApiProperty({ type: 'integer', format: 'int64' }) + quotaSizeInBytes?: number | null; +} + +export class UserDto { + id!: string; + name!: string; + email!: string; + profileImagePath!: string; + @IsEnum(UserAvatarColor) + @ApiProperty({ enumName: 'UserAvatarColor', enum: UserAvatarColor }) + avatarColor!: UserAvatarColor; +} + +export class UserResponseDto extends UserDto { + storageLabel!: string | null; + shouldChangePassword!: boolean; + isAdmin!: boolean; + createdAt!: Date; + deletedAt!: Date | null; + updatedAt!: Date; + oauthId!: string; + memoriesEnabled?: boolean; + @ApiProperty({ type: 'integer', format: 'int64' }) + quotaSizeInBytes!: number | null; + @ApiProperty({ type: 'integer', format: 'int64' }) + quotaUsageInBytes!: number | null; + @ApiProperty({ enumName: 'UserStatus', enum: UserStatus }) + status!: string; +} + +export const mapSimpleUser = (entity: UserEntity): UserDto => { + return { + id: entity.id, + email: entity.email, + name: entity.name, + profileImagePath: entity.profileImagePath, + avatarColor: entity.avatarColor ?? getRandomAvatarColor(entity), + }; +}; + +export function mapUser(entity: UserEntity): UserResponseDto { + return { + ...mapSimpleUser(entity), + storageLabel: entity.storageLabel, + shouldChangePassword: entity.shouldChangePassword, + isAdmin: entity.isAdmin, + createdAt: entity.createdAt, + deletedAt: entity.deletedAt, + updatedAt: entity.updatedAt, + oauthId: entity.oauthId, + memoriesEnabled: entity.memoriesEnabled, + quotaSizeInBytes: entity.quotaSizeInBytes, + quotaUsageInBytes: entity.quotaUsageInBytes, + status: entity.status, + }; +} diff --git a/server/src/immich/api-v1/asset/asset.controller.ts b/server/src/immich/api-v1/asset/asset.controller.ts index d29f61fdda..5f57eb5584 100644 --- a/server/src/immich/api-v1/asset/asset.controller.ts +++ b/server/src/immich/api-v1/asset/asset.controller.ts @@ -15,8 +15,8 @@ import { } from '@nestjs/common'; import { ApiBody, ApiConsumes, ApiHeader, ApiTags } from '@nestjs/swagger'; import { NextFunction, Response } from 'express'; -import { AssetResponseDto } from 'src/domain/asset/response-dto/asset-response.dto'; -import { AuthDto } from 'src/domain/auth/auth.dto'; +import { AssetResponseDto } from 'src/dtos/asset-response.dto'; +import { AuthDto } from 'src/dtos/auth.dto'; import { AssetService as AssetServiceV1 } from 'src/immich/api-v1/asset/asset.service'; import { AssetBulkUploadCheckDto } from 'src/immich/api-v1/asset/dto/asset-check.dto'; import { AssetSearchDto } from 'src/immich/api-v1/asset/dto/asset-search.dto'; diff --git a/server/src/immich/api-v1/asset/asset.service.ts b/server/src/immich/api-v1/asset/asset.service.ts index 0a57226901..ee310c3771 100644 --- a/server/src/immich/api-v1/asset/asset.service.ts +++ b/server/src/immich/api-v1/asset/asset.service.ts @@ -7,10 +7,10 @@ import { } from '@nestjs/common'; import { AccessCore, Permission } from 'src/cores/access.core'; import { UploadFile } from 'src/domain/asset/asset.service'; -import { AssetResponseDto, mapAsset } from 'src/domain/asset/response-dto/asset-response.dto'; -import { AuthDto } from 'src/domain/auth/auth.dto'; import { mimeTypes } from 'src/domain/domain.constant'; import { JobName } from 'src/domain/job/job.constants'; +import { AssetResponseDto, mapAsset } from 'src/dtos/asset-response.dto'; +import { AuthDto } from 'src/dtos/auth.dto'; import { ASSET_CHECKSUM_CONSTRAINT, AssetEntity, AssetType } from 'src/entities/asset.entity'; import { LibraryType } from 'src/entities/library.entity'; import { IAssetRepositoryV1 } from 'src/immich/api-v1/asset/asset-repository'; diff --git a/server/src/immich/api-v1/asset/dto/create-asset.dto.ts b/server/src/immich/api-v1/asset/dto/create-asset.dto.ts index d16a9c05cd..7e5b9a0c8b 100644 --- a/server/src/immich/api-v1/asset/dto/create-asset.dto.ts +++ b/server/src/immich/api-v1/asset/dto/create-asset.dto.ts @@ -1,6 +1,6 @@ import { ApiProperty } from '@nestjs/swagger'; import { IsNotEmpty, IsString } from 'class-validator'; -import { UploadFieldName } from 'src/domain/asset/asset.service'; +import { UploadFieldName } from 'src/dtos/asset.dto'; import { Optional, ValidateBoolean, ValidateDate, ValidateUUID } from 'src/validation'; export class CreateAssetDto { diff --git a/server/src/interfaces/communication.repository.ts b/server/src/interfaces/communication.repository.ts index 870c0d9375..4627e52655 100644 --- a/server/src/interfaces/communication.repository.ts +++ b/server/src/interfaces/communication.repository.ts @@ -1,5 +1,5 @@ -import { AssetResponseDto } from 'src/domain/asset/response-dto/asset-response.dto'; -import { ReleaseNotification, ServerVersionResponseDto } from 'src/domain/server-info/server-info.dto'; +import { AssetResponseDto } from 'src/dtos/asset-response.dto'; +import { ReleaseNotification, ServerVersionResponseDto } from 'src/dtos/server-info.dto'; import { SystemConfig } from 'src/entities/system-config.entity'; export const ICommunicationRepository = 'ICommunicationRepository'; diff --git a/server/src/interfaces/library.repository.ts b/server/src/interfaces/library.repository.ts index 5638d60249..dbc7fab812 100644 --- a/server/src/interfaces/library.repository.ts +++ b/server/src/interfaces/library.repository.ts @@ -1,4 +1,4 @@ -import { LibraryStatsResponseDto } from 'src/domain/library/library.dto'; +import { LibraryStatsResponseDto } from 'src/dtos/library.dto'; import { LibraryEntity, LibraryType } from 'src/entities/library.entity'; export const ILibraryRepository = 'ILibraryRepository'; diff --git a/server/src/interfaces/machine-learning.repository.ts b/server/src/interfaces/machine-learning.repository.ts index d11e2e8f70..0aeed7635a 100644 --- a/server/src/interfaces/machine-learning.repository.ts +++ b/server/src/interfaces/machine-learning.repository.ts @@ -1,4 +1,4 @@ -import { CLIPConfig, RecognitionConfig } from 'src/domain/smart-info/dto/model-config.dto'; +import { CLIPConfig, RecognitionConfig } from 'src/dtos/model-config.dto'; export const IMachineLearningRepository = 'IMachineLearningRepository'; diff --git a/server/src/interfaces/storage.repository.ts b/server/src/interfaces/storage.repository.ts index 505e535b08..e78bb0195d 100644 --- a/server/src/interfaces/storage.repository.ts +++ b/server/src/interfaces/storage.repository.ts @@ -2,7 +2,7 @@ import { WatchOptions } from 'chokidar'; import { Stats } from 'node:fs'; import { FileReadOptions } from 'node:fs/promises'; import { Readable } from 'node:stream'; -import { CrawlOptionsDto } from 'src/domain/library/library.dto'; +import { CrawlOptionsDto } from 'src/dtos/library.dto'; export interface ImmichReadStream { stream: Readable; diff --git a/server/src/middleware/auth.guard.ts b/server/src/middleware/auth.guard.ts index 070bf15e86..765e243543 100644 --- a/server/src/middleware/auth.guard.ts +++ b/server/src/middleware/auth.guard.ts @@ -10,8 +10,8 @@ import { Reflector } from '@nestjs/core'; import { ApiBearerAuth, ApiCookieAuth, ApiOkResponse, ApiQuery, ApiSecurity } from '@nestjs/swagger'; import { Request } from 'express'; import { IMMICH_API_KEY_NAME } from 'src/domain/auth/auth.constant'; -import { AuthDto } from 'src/domain/auth/auth.dto'; import { AuthService, LoginDetails } from 'src/domain/auth/auth.service'; +import { AuthDto } from 'src/dtos/auth.dto'; import { ImmichLogger } from 'src/infra/logger'; import { UAParser } from 'ua-parser-js'; diff --git a/server/src/middleware/file-upload.interceptor.ts b/server/src/middleware/file-upload.interceptor.ts index a7598f99d5..9d6abaa3d1 100644 --- a/server/src/middleware/file-upload.interceptor.ts +++ b/server/src/middleware/file-upload.interceptor.ts @@ -6,7 +6,8 @@ import { NextFunction, RequestHandler } from 'express'; import multer, { StorageEngine, diskStorage } from 'multer'; import { createHash, randomUUID } from 'node:crypto'; import { Observable } from 'rxjs'; -import { AssetService, UploadFieldName, UploadFile } from 'src/domain/asset/asset.service'; +import { AssetService, UploadFile } from 'src/domain/asset/asset.service'; +import { UploadFieldName } from 'src/dtos/asset.dto'; import { ImmichLogger } from 'src/infra/logger'; import { AuthRequest } from 'src/middleware/auth.guard'; diff --git a/server/src/repositories/filesystem.provider.spec.ts b/server/src/repositories/filesystem.provider.spec.ts index 56f54b0360..c9790767ce 100644 --- a/server/src/repositories/filesystem.provider.spec.ts +++ b/server/src/repositories/filesystem.provider.spec.ts @@ -1,5 +1,5 @@ import mockfs from 'mock-fs'; -import { CrawlOptionsDto } from 'src/domain/library/library.dto'; +import { CrawlOptionsDto } from 'src/dtos/library.dto'; import { FilesystemProvider } from 'src/repositories/filesystem.provider'; interface Test { diff --git a/server/src/repositories/filesystem.provider.ts b/server/src/repositories/filesystem.provider.ts index 2da49625ed..1e65f96647 100644 --- a/server/src/repositories/filesystem.provider.ts +++ b/server/src/repositories/filesystem.provider.ts @@ -5,7 +5,7 @@ import { constants, createReadStream, existsSync, mkdirSync } from 'node:fs'; import fs from 'node:fs/promises'; import path from 'node:path'; import { mimeTypes } from 'src/domain/domain.constant'; -import { CrawlOptionsDto } from 'src/domain/library/library.dto'; +import { CrawlOptionsDto } from 'src/dtos/library.dto'; import { Instrumentation } from 'src/infra/instrumentation'; import { ImmichLogger } from 'src/infra/logger'; import { diff --git a/server/src/repositories/library.repository.ts b/server/src/repositories/library.repository.ts index 7171aad0d8..152f544ce7 100644 --- a/server/src/repositories/library.repository.ts +++ b/server/src/repositories/library.repository.ts @@ -1,7 +1,7 @@ import { Injectable } from '@nestjs/common'; import { InjectRepository } from '@nestjs/typeorm'; import { DummyValue, GenerateSql } from 'src/decorators'; -import { LibraryStatsResponseDto } from 'src/domain/library/library.dto'; +import { LibraryStatsResponseDto } from 'src/dtos/library.dto'; import { LibraryEntity, LibraryType } from 'src/entities/library.entity'; import { Instrumentation } from 'src/infra/instrumentation'; import { ILibraryRepository } from 'src/interfaces/library.repository'; diff --git a/server/src/repositories/machine-learning.repository.ts b/server/src/repositories/machine-learning.repository.ts index 46d16dcd7a..34f0cdbfc5 100644 --- a/server/src/repositories/machine-learning.repository.ts +++ b/server/src/repositories/machine-learning.repository.ts @@ -1,6 +1,6 @@ import { Injectable } from '@nestjs/common'; import { readFile } from 'node:fs/promises'; -import { CLIPConfig, ModelConfig, RecognitionConfig } from 'src/domain/smart-info/dto/model-config.dto'; +import { CLIPConfig, ModelConfig, RecognitionConfig } from 'src/dtos/model-config.dto'; import { Instrumentation } from 'src/infra/instrumentation'; import { CLIPMode, diff --git a/server/test/fixtures/auth.stub.ts b/server/test/fixtures/auth.stub.ts index e0add44d23..2e56d0001a 100644 --- a/server/test/fixtures/auth.stub.ts +++ b/server/test/fixtures/auth.stub.ts @@ -1,4 +1,4 @@ -import { AuthDto } from 'src/domain/auth/auth.dto'; +import { AuthDto } from 'src/dtos/auth.dto'; import { SharedLinkEntity } from 'src/entities/shared-link.entity'; import { UserTokenEntity } from 'src/entities/user-token.entity'; import { UserEntity } from 'src/entities/user.entity'; diff --git a/server/test/fixtures/shared-link.stub.ts b/server/test/fixtures/shared-link.stub.ts index 6855c8c7a2..34e3da5156 100644 --- a/server/test/fixtures/shared-link.stub.ts +++ b/server/test/fixtures/shared-link.stub.ts @@ -1,8 +1,8 @@ -import { AlbumResponseDto } from 'src/domain/album/album-response.dto'; -import { AssetResponseDto } from 'src/domain/asset/response-dto/asset-response.dto'; -import { ExifResponseDto } from 'src/domain/asset/response-dto/exif-response.dto'; -import { SharedLinkResponseDto } from 'src/domain/shared-link/shared-link-response.dto'; -import { mapUser } from 'src/domain/user/response-dto/user-response.dto'; +import { AlbumResponseDto } from 'src/dtos/album.dto'; +import { AssetResponseDto } from 'src/dtos/asset-response.dto'; +import { ExifResponseDto } from 'src/dtos/exif.dto'; +import { SharedLinkResponseDto } from 'src/dtos/shared-link.dto'; +import { mapUser } from 'src/dtos/user.dto'; import { AssetOrder } from 'src/entities/album.entity'; import { AssetType } from 'src/entities/asset.entity'; import { SharedLinkEntity, SharedLinkType } from 'src/entities/shared-link.entity'; diff --git a/server/test/fixtures/tag.stub.ts b/server/test/fixtures/tag.stub.ts index 27123ddb67..537c65db47 100644 --- a/server/test/fixtures/tag.stub.ts +++ b/server/test/fixtures/tag.stub.ts @@ -1,4 +1,4 @@ -import { TagResponseDto } from 'src/domain/tag/tag-response.dto'; +import { TagResponseDto } from 'src/dtos/tag.dto'; import { TagEntity, TagType } from 'src/entities/tag.entity'; import { userStub } from 'test/fixtures/user.stub';