From bff6914a7372b2691fa22a3498ce14357b9afe5e Mon Sep 17 00:00:00 2001 From: Jason Rasmussen Date: Fri, 16 Jun 2023 15:54:17 -0400 Subject: [PATCH] chore(server): organize imports (#2779) * feat: lint rule for organize imports * chore: organize imports --- server/.prettierrc | 3 +- server/e2e/album.e2e-spec.ts | 15 ++- server/e2e/user.e2e-spec.ts | 13 ++- server/package-lock.json | 28 ++++++ server/package.json | 1 + server/src/domain/album/album.service.spec.ts | 2 +- .../domain/album/dto/album-add-users.dto.ts | 2 +- .../src/domain/album/dto/album-create.dto.ts | 2 +- .../src/domain/album/dto/album-update.dto.ts | 2 +- server/src/domain/album/dto/get-albums.dto.ts | 4 +- server/src/domain/asset/dto/map-marker.dto.ts | 2 +- server/src/domain/auth/auth.service.spec.ts | 6 +- server/src/domain/auth/auth.service.ts | 22 +++-- server/src/domain/facial-recognition/index.ts | 2 +- server/src/domain/job/job.service.spec.ts | 2 +- .../domain/metadata/metadata.service.spec.ts | 2 +- server/src/domain/oauth/oauth.service.spec.ts | 2 +- server/src/domain/partner/partner.service.ts | 2 +- .../src/domain/person/person.service.spec.ts | 2 +- server/src/domain/search/dto/search.dto.ts | 2 +- .../src/domain/search/search.service.spec.ts | 2 +- .../server-version-response.dto.ts | 2 +- server/src/domain/shared-link/index.ts | 2 +- .../shared-link/shared-link.service.spec.ts | 2 +- .../storage-template.service.spec.ts | 4 +- .../dto/system-config-ffmpeg.dto.ts | 4 +- .../system-config/dto/system-config.dto.ts | 2 +- .../system-config/system-config.service.ts | 8 +- server/src/domain/tag/tag.service.spec.ts | 2 +- server/src/domain/user-token/index.ts | 2 +- server/src/domain/user/dto/create-user.dto.ts | 2 +- server/src/domain/user/dto/update-user.dto.ts | 2 +- server/src/domain/user/user.service.spec.ts | 2 +- server/src/domain/user/user.service.ts | 2 +- .../src/immich/api-v1/album/album.module.ts | 10 +- .../src/immich/api-v1/album/album.service.ts | 29 +++--- .../album/dto/create-album-shared-link.dto.ts | 2 +- .../response-dto/add-assets-response.dto.ts | 2 +- .../immich/api-v1/asset/asset-repository.ts | 22 ++--- .../immich/api-v1/asset/asset.controller.ts | 95 +++++++++--------- server/src/immich/api-v1/asset/asset.core.ts | 2 +- .../src/immich/api-v1/asset/asset.module.ts | 10 +- .../immich/api-v1/asset/asset.service.spec.ts | 22 ++--- .../src/immich/api-v1/asset/asset.service.ts | 98 ++++++++++--------- .../api-v1/validation/parse-me-uuid-pipe.ts | 2 +- .../src/immich/controllers/app.controller.ts | 2 +- .../immich/controllers/asset.controller.ts | 2 +- .../src/immich/controllers/job.controller.ts | 2 +- .../immich/controllers/partner.controller.ts | 2 +- .../src/immich/controllers/tag.controller.ts | 2 +- .../src/immich/controllers/user.controller.ts | 42 ++++---- .../modules/download/download.service.ts | 2 +- server/src/infra/communication.gateway.ts | 2 +- server/src/infra/entities/album.entity.ts | 2 +- server/src/infra/entities/partner.entity.ts | 2 +- .../infra/entities/system-config.entity.ts | 2 +- server/src/infra/redis-io.adapter.ts | 2 +- .../infra/repositories/crypto.repository.ts | 2 +- .../infra/repositories/media.repository.ts | 2 +- .../repositories/user-token.repository.ts | 2 +- server/src/main.ts | 2 +- .../utils/exif/coordinates.spec.ts | 2 +- .../src/microservices/utils/exif/iso.spec.ts | 2 +- .../src/microservices/utils/numbers.spec.ts | 2 +- server/test/fixtures.ts | 30 +++--- server/test/index.ts | 2 +- server/test/test-utils.ts | 4 +- 67 files changed, 300 insertions(+), 262 deletions(-) diff --git a/server/.prettierrc b/server/.prettierrc index 7cebf3813c..a095d3a516 100644 --- a/server/.prettierrc +++ b/server/.prettierrc @@ -2,5 +2,6 @@ "singleQuote": true, "trailingComma": "all", "printWidth": 120, - "semi": true + "semi": true, + "organizeImportsSkipDestructiveCodeActions": true } diff --git a/server/e2e/album.e2e-spec.ts b/server/e2e/album.e2e-spec.ts index e75a680469..7f2396b275 100644 --- a/server/e2e/album.e2e-spec.ts +++ b/server/e2e/album.e2e-spec.ts @@ -1,13 +1,12 @@ -import { Test, TestingModule } from '@nestjs/testing'; -import { INestApplication } from '@nestjs/common'; -import request from 'supertest'; -import { clearDb, getAuthUser, authCustom } from '../test/test-utils'; -import { CreateAlbumDto } from '@app/domain'; +import { AlbumResponseDto, AuthService, CreateAlbumDto, SharedLinkResponseDto, UserService } from '@app/domain'; import { CreateAlbumShareLinkDto } from '@app/immich/api-v1/album/dto/create-album-shared-link.dto'; -import { AuthUserDto } from '@app/immich/decorators/auth-user.decorator'; -import { AlbumResponseDto, AuthService, SharedLinkResponseDto, UserService } from '@app/domain'; -import { DataSource } from 'typeorm'; import { AppModule } from '@app/immich/app.module'; +import { AuthUserDto } from '@app/immich/decorators/auth-user.decorator'; +import { INestApplication } from '@nestjs/common'; +import { Test, TestingModule } from '@nestjs/testing'; +import request from 'supertest'; +import { DataSource } from 'typeorm'; +import { authCustom, clearDb, getAuthUser } from '../test/test-utils'; async function _createAlbum(app: INestApplication, data: CreateAlbumDto) { const res = await request(app.getHttpServer()).post('/album').send(data); diff --git a/server/e2e/user.e2e-spec.ts b/server/e2e/user.e2e-spec.ts index 6c72d9091c..d74626cb3a 100644 --- a/server/e2e/user.e2e-spec.ts +++ b/server/e2e/user.e2e-spec.ts @@ -1,11 +1,10 @@ -import { Test, TestingModule } from '@nestjs/testing'; -import { INestApplication } from '@nestjs/common'; -import request from 'supertest'; -import { clearDb, authCustom } from '../test/test-utils'; -import { CreateUserDto, UserService, AuthUserDto, UserResponseDto } from '@app/domain'; -import { DataSource } from 'typeorm'; -import { AuthService } from '@app/domain'; +import { AuthService, AuthUserDto, CreateUserDto, UserResponseDto, UserService } from '@app/domain'; import { AppModule } from '@app/immich/app.module'; +import { INestApplication } from '@nestjs/common'; +import { Test, TestingModule } from '@nestjs/testing'; +import request from 'supertest'; +import { DataSource } from 'typeorm'; +import { authCustom, clearDb } from '../test/test-utils'; function _createUser(userService: UserService, data: CreateUserDto) { return userService.createUser(data); diff --git a/server/package-lock.json b/server/package-lock.json index aefb2d6504..7819b42c1c 100644 --- a/server/package-lock.json +++ b/server/package-lock.json @@ -83,6 +83,7 @@ "jest": "^27.2.5", "jest-when": "^3.5.2", "prettier": "^2.3.2", + "prettier-plugin-organize-imports": "^3.2.2", "rimraf": "^3.0.2", "source-map-support": "^0.5.20", "supertest": "^6.1.3", @@ -9374,6 +9375,26 @@ "node": ">=6.0.0" } }, + "node_modules/prettier-plugin-organize-imports": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/prettier-plugin-organize-imports/-/prettier-plugin-organize-imports-3.2.2.tgz", + "integrity": "sha512-e97lE6odGSiHonHJMTYC0q0iLXQyw0u5z/PJpvP/3vRy6/Zi9kLBwFAbEGjDzIowpjQv8b+J04PDamoUSQbzGA==", + "dev": true, + "peerDependencies": { + "@volar/vue-language-plugin-pug": "^1.0.4", + "@volar/vue-typescript": "^1.0.4", + "prettier": ">=2.0", + "typescript": ">=2.9" + }, + "peerDependenciesMeta": { + "@volar/vue-language-plugin-pug": { + "optional": true + }, + "@volar/vue-typescript": { + "optional": true + } + } + }, "node_modules/pretty-format": { "version": "27.5.1", "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-27.5.1.tgz", @@ -19106,6 +19127,13 @@ "fast-diff": "^1.1.2" } }, + "prettier-plugin-organize-imports": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/prettier-plugin-organize-imports/-/prettier-plugin-organize-imports-3.2.2.tgz", + "integrity": "sha512-e97lE6odGSiHonHJMTYC0q0iLXQyw0u5z/PJpvP/3vRy6/Zi9kLBwFAbEGjDzIowpjQv8b+J04PDamoUSQbzGA==", + "dev": true, + "requires": {} + }, "pretty-format": { "version": "27.5.1", "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-27.5.1.tgz", diff --git a/server/package.json b/server/package.json index f70f25aacc..1cce78e016 100644 --- a/server/package.json +++ b/server/package.json @@ -109,6 +109,7 @@ "jest": "^27.2.5", "jest-when": "^3.5.2", "prettier": "^2.3.2", + "prettier-plugin-organize-imports": "^3.2.2", "rimraf": "^3.0.2", "source-map-support": "^0.5.20", "supertest": "^6.1.3", diff --git a/server/src/domain/album/album.service.spec.ts b/server/src/domain/album/album.service.spec.ts index aeb9d0da31..67e031db55 100644 --- a/server/src/domain/album/album.service.spec.ts +++ b/server/src/domain/album/album.service.spec.ts @@ -1,5 +1,4 @@ import { BadRequestException, ForbiddenException } from '@nestjs/common'; -import _ from 'lodash'; import { albumStub, authStub, @@ -9,6 +8,7 @@ import { newUserRepositoryMock, userEntityStub, } from '@test'; +import _ from 'lodash'; import { IAssetRepository } from '../asset'; import { IJobRepository, JobName } from '../job'; import { IUserRepository } from '../user'; diff --git a/server/src/domain/album/dto/album-add-users.dto.ts b/server/src/domain/album/dto/album-add-users.dto.ts index 7546cdc3be..39ecb7b50c 100644 --- a/server/src/domain/album/dto/album-add-users.dto.ts +++ b/server/src/domain/album/dto/album-add-users.dto.ts @@ -1,5 +1,5 @@ -import { ArrayNotEmpty } from 'class-validator'; import { ValidateUUID } from '@app/immich/decorators/validate-uuid.decorator'; +import { ArrayNotEmpty } from 'class-validator'; export class AddUsersDto { @ValidateUUID({ each: true }) diff --git a/server/src/domain/album/dto/album-create.dto.ts b/server/src/domain/album/dto/album-create.dto.ts index c41d9120d8..2edef34573 100644 --- a/server/src/domain/album/dto/album-create.dto.ts +++ b/server/src/domain/album/dto/album-create.dto.ts @@ -1,5 +1,5 @@ -import { ApiProperty } from '@nestjs/swagger'; import { ValidateUUID } from '@app/immich/decorators/validate-uuid.decorator'; +import { ApiProperty } from '@nestjs/swagger'; import { IsNotEmpty, IsString } from 'class-validator'; export class CreateAlbumDto { diff --git a/server/src/domain/album/dto/album-update.dto.ts b/server/src/domain/album/dto/album-update.dto.ts index fb1e793364..9388eac67a 100644 --- a/server/src/domain/album/dto/album-update.dto.ts +++ b/server/src/domain/album/dto/album-update.dto.ts @@ -1,6 +1,6 @@ +import { ValidateUUID } from '@app/immich/decorators/validate-uuid.decorator'; import { ApiProperty } from '@nestjs/swagger'; import { IsOptional } from 'class-validator'; -import { ValidateUUID } from '@app/immich/decorators/validate-uuid.decorator'; export class UpdateAlbumDto { @IsOptional() diff --git a/server/src/domain/album/dto/get-albums.dto.ts b/server/src/domain/album/dto/get-albums.dto.ts index 9b22d61162..6a76478819 100644 --- a/server/src/domain/album/dto/get-albums.dto.ts +++ b/server/src/domain/album/dto/get-albums.dto.ts @@ -1,8 +1,8 @@ +import { ValidateUUID } from '@app/immich/decorators/validate-uuid.decorator'; +import { toBoolean } from '@app/immich/utils/transform.util'; import { ApiProperty } from '@nestjs/swagger'; import { Transform } from 'class-transformer'; import { IsBoolean, IsOptional } from 'class-validator'; -import { ValidateUUID } from '@app/immich/decorators/validate-uuid.decorator'; -import { toBoolean } from '@app/immich/utils/transform.util'; export class GetAlbumsDto { @IsOptional() diff --git a/server/src/domain/asset/dto/map-marker.dto.ts b/server/src/domain/asset/dto/map-marker.dto.ts index 95db3067e6..a8e3b79243 100644 --- a/server/src/domain/asset/dto/map-marker.dto.ts +++ b/server/src/domain/asset/dto/map-marker.dto.ts @@ -1,7 +1,7 @@ +import { toBoolean } from '@app/immich/utils/transform.util'; import { ApiProperty } from '@nestjs/swagger'; import { Transform, Type } from 'class-transformer'; import { IsBoolean, IsDate, IsOptional } from 'class-validator'; -import { toBoolean } from '@app/immich/utils/transform.util'; export class MapMarkerDto { @ApiProperty() diff --git a/server/src/domain/auth/auth.service.spec.ts b/server/src/domain/auth/auth.service.spec.ts index 08d131ba3e..43d31f15b3 100644 --- a/server/src/domain/auth/auth.service.spec.ts +++ b/server/src/domain/auth/auth.service.spec.ts @@ -1,8 +1,5 @@ import { SystemConfig, UserEntity } from '@app/infra/entities'; import { BadRequestException, UnauthorizedException } from '@nestjs/common'; -import { IncomingHttpHeaders } from 'http'; -import { generators, Issuer } from 'openid-client'; -import { Socket } from 'socket.io'; import { authStub, keyStub, @@ -18,6 +15,9 @@ import { userEntityStub, userTokenEntityStub, } from '@test'; +import { IncomingHttpHeaders } from 'http'; +import { generators, Issuer } from 'openid-client'; +import { Socket } from 'socket.io'; import { IKeyRepository } from '../api-key'; import { ICryptoRepository } from '../crypto/crypto.repository'; import { ISharedLinkRepository } from '../shared-link'; diff --git a/server/src/domain/auth/auth.service.ts b/server/src/domain/auth/auth.service.ts index 786c4597bd..ebc5ddefbc 100644 --- a/server/src/domain/auth/auth.service.ts +++ b/server/src/domain/auth/auth.service.ts @@ -7,21 +7,27 @@ import { Logger, UnauthorizedException, } from '@nestjs/common'; +import cookieParser from 'cookie'; import { IncomingHttpHeaders } from 'http'; +import { IKeyRepository } from '../api-key'; +import { APIKeyCore } from '../api-key/api-key.core'; +import { ICryptoRepository } from '../crypto/crypto.repository'; import { OAuthCore } from '../oauth/oauth.core'; +import { ISharedLinkRepository, SharedLinkCore } from '../shared-link'; import { INITIAL_SYSTEM_CONFIG, ISystemConfigRepository } from '../system-config'; import { IUserRepository, UserCore } from '../user'; +import { IUserTokenRepository, UserTokenCore } from '../user-token'; import { AuthType, IMMICH_ACCESS_COOKIE, IMMICH_API_KEY_HEADER } from './auth.constant'; import { AuthCore, LoginDetails } from './auth.core'; -import { ICryptoRepository } from '../crypto/crypto.repository'; import { AuthUserDto, ChangePasswordDto, LoginCredentialDto, SignUpDto } from './dto'; -import { AdminSignupResponseDto, LoginResponseDto, LogoutResponseDto, mapAdminSignupResponse } from './response-dto'; -import { IUserTokenRepository, UserTokenCore } from '../user-token'; -import cookieParser from 'cookie'; -import { ISharedLinkRepository, SharedLinkCore } from '../shared-link'; -import { APIKeyCore } from '../api-key/api-key.core'; -import { IKeyRepository } from '../api-key'; -import { AuthDeviceResponseDto, mapUserToken } from './response-dto'; +import { + AdminSignupResponseDto, + AuthDeviceResponseDto, + LoginResponseDto, + LogoutResponseDto, + mapAdminSignupResponse, + mapUserToken, +} from './response-dto'; @Injectable() export class AuthService { diff --git a/server/src/domain/facial-recognition/index.ts b/server/src/domain/facial-recognition/index.ts index affe817a02..d07ea558cf 100644 --- a/server/src/domain/facial-recognition/index.ts +++ b/server/src/domain/facial-recognition/index.ts @@ -1,2 +1,2 @@ -export * from './facial-recognition.services'; export * from './face.repository'; +export * from './facial-recognition.services'; diff --git a/server/src/domain/job/job.service.spec.ts b/server/src/domain/job/job.service.spec.ts index 23999d5d3b..391a40d929 100644 --- a/server/src/domain/job/job.service.spec.ts +++ b/server/src/domain/job/job.service.spec.ts @@ -7,9 +7,9 @@ import { newJobRepositoryMock, newSystemConfigRepositoryMock, } from '@test'; +import { IJobRepository, JobCommand, JobHandler, JobItem, JobName, JobService, QueueName } from '.'; import { IAssetRepository } from '../asset'; import { ICommunicationRepository } from '../communication'; -import { IJobRepository, JobCommand, JobHandler, JobItem, JobName, JobService, QueueName } from '.'; import { ISystemConfigRepository } from '../system-config'; import { SystemConfigCore } from '../system-config/system-config.core'; diff --git a/server/src/domain/metadata/metadata.service.spec.ts b/server/src/domain/metadata/metadata.service.spec.ts index cc47b2abf9..1052d75850 100644 --- a/server/src/domain/metadata/metadata.service.spec.ts +++ b/server/src/domain/metadata/metadata.service.spec.ts @@ -1,5 +1,5 @@ -import { constants } from 'fs/promises'; import { assetEntityStub, newAssetRepositoryMock, newJobRepositoryMock, newStorageRepositoryMock } from '@test'; +import { constants } from 'fs/promises'; import { IAssetRepository, WithoutProperty, WithProperty } from '../asset'; import { IJobRepository, JobName } from '../job'; import { IStorageRepository } from '../storage'; diff --git a/server/src/domain/oauth/oauth.service.spec.ts b/server/src/domain/oauth/oauth.service.spec.ts index 74dac63f50..8b5d9f7cd3 100644 --- a/server/src/domain/oauth/oauth.service.spec.ts +++ b/server/src/domain/oauth/oauth.service.spec.ts @@ -1,6 +1,5 @@ import { SystemConfig, UserEntity } from '@app/infra/entities'; import { BadRequestException } from '@nestjs/common'; -import { generators, Issuer } from 'openid-client'; import { authStub, loginResponseStub, @@ -12,6 +11,7 @@ import { userEntityStub, userTokenEntityStub, } from '@test'; +import { generators, Issuer } from 'openid-client'; import { OAuthService } from '.'; import { LoginDetails } from '../auth'; import { ICryptoRepository } from '../crypto'; diff --git a/server/src/domain/partner/partner.service.ts b/server/src/domain/partner/partner.service.ts index d870dc115f..3cf92d3e54 100644 --- a/server/src/domain/partner/partner.service.ts +++ b/server/src/domain/partner/partner.service.ts @@ -1,7 +1,7 @@ import { PartnerEntity } from '@app/infra/entities'; import { BadRequestException, Inject, Injectable } from '@nestjs/common'; -import { AuthUserDto } from '../auth'; import { IPartnerRepository, PartnerDirection, PartnerIds } from '.'; +import { AuthUserDto } from '../auth'; import { mapUser, UserResponseDto } from '../user'; @Injectable() diff --git a/server/src/domain/person/person.service.spec.ts b/server/src/domain/person/person.service.spec.ts index 9a9f3107d8..d431e94af1 100644 --- a/server/src/domain/person/person.service.spec.ts +++ b/server/src/domain/person/person.service.spec.ts @@ -1,5 +1,4 @@ import { BadRequestException, NotFoundException } from '@nestjs/common'; -import { IJobRepository, JobName } from '..'; import { assetEntityStub, authStub, @@ -8,6 +7,7 @@ import { newStorageRepositoryMock, personStub, } from '@test'; +import { IJobRepository, JobName } from '..'; import { IStorageRepository } from '../storage'; import { IPersonRepository } from './person.repository'; import { PersonService } from './person.service'; diff --git a/server/src/domain/search/dto/search.dto.ts b/server/src/domain/search/dto/search.dto.ts index 9c442260b9..5a11c68dea 100644 --- a/server/src/domain/search/dto/search.dto.ts +++ b/server/src/domain/search/dto/search.dto.ts @@ -1,7 +1,7 @@ +import { toBoolean } from '@app/immich/utils/transform.util'; import { AssetType } from '@app/infra/entities'; import { Transform } from 'class-transformer'; import { IsArray, IsBoolean, IsEnum, IsNotEmpty, IsOptional, IsString } from 'class-validator'; -import { toBoolean } from '@app/immich/utils/transform.util'; export class SearchDto { @IsString() diff --git a/server/src/domain/search/search.service.spec.ts b/server/src/domain/search/search.service.spec.ts index e1ff835d06..966e2de8d3 100644 --- a/server/src/domain/search/search.service.spec.ts +++ b/server/src/domain/search/search.service.spec.ts @@ -1,6 +1,5 @@ import { BadRequestException } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; -import { plainToInstance } from 'class-transformer'; import { albumStub, assetEntityStub, @@ -15,6 +14,7 @@ import { newSearchRepositoryMock, searchStub, } from '@test'; +import { plainToInstance } from 'class-transformer'; import { IAlbumRepository } from '../album/album.repository'; import { IAssetRepository } from '../asset/asset.repository'; import { IFaceRepository } from '../facial-recognition'; diff --git a/server/src/domain/server-info/response-dto/server-version-response.dto.ts b/server/src/domain/server-info/response-dto/server-version-response.dto.ts index a4c7eeca41..373fa734f8 100644 --- a/server/src/domain/server-info/response-dto/server-version-response.dto.ts +++ b/server/src/domain/server-info/response-dto/server-version-response.dto.ts @@ -1,5 +1,5 @@ -import { ApiProperty } from '@nestjs/swagger'; import { IServerVersion } from '@app/domain'; +import { ApiProperty } from '@nestjs/swagger'; export class ServerVersionReponseDto implements IServerVersion { @ApiProperty({ type: 'integer' }) diff --git a/server/src/domain/shared-link/index.ts b/server/src/domain/shared-link/index.ts index 105ac9a77b..d97d103301 100644 --- a/server/src/domain/shared-link/index.ts +++ b/server/src/domain/shared-link/index.ts @@ -1,5 +1,5 @@ export * from './dto'; export * from './response-dto'; export * from './shared-link.core'; -export * from './shared-link.service'; export * from './shared-link.repository'; +export * from './shared-link.service'; 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 52cf7469b3..1c269784c6 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 } from '@nestjs/common'; import { authStub, newSharedLinkRepositoryMock, sharedLinkResponseStub, sharedLinkStub } from '@test'; -import { SharedLinkService } from './shared-link.service'; import { ISharedLinkRepository } from './shared-link.repository'; +import { SharedLinkService } from './shared-link.service'; describe(SharedLinkService.name, () => { let sut: SharedLinkService; diff --git a/server/src/domain/storage-template/storage-template.service.spec.ts b/server/src/domain/storage-template/storage-template.service.spec.ts index 166ba4695c..812ccc7e36 100644 --- a/server/src/domain/storage-template/storage-template.service.spec.ts +++ b/server/src/domain/storage-template/storage-template.service.spec.ts @@ -1,4 +1,3 @@ -import { when } from 'jest-when'; import { assetEntityStub, newAssetRepositoryMock, @@ -8,8 +7,9 @@ import { systemConfigStub, userEntityStub, } from '@test'; -import { IAssetRepository } from '../asset'; +import { when } from 'jest-when'; import { StorageTemplateService } from '.'; +import { IAssetRepository } from '../asset'; import { IStorageRepository } from '../storage/storage.repository'; import { ISystemConfigRepository } from '../system-config'; import { IUserRepository } from '../user'; diff --git a/server/src/domain/system-config/dto/system-config-ffmpeg.dto.ts b/server/src/domain/system-config/dto/system-config-ffmpeg.dto.ts index e47ad99630..1a641828d3 100644 --- a/server/src/domain/system-config/dto/system-config-ffmpeg.dto.ts +++ b/server/src/domain/system-config/dto/system-config-ffmpeg.dto.ts @@ -1,7 +1,7 @@ -import { IsEnum, IsString, IsInt, IsBoolean, Min, Max } from 'class-validator'; import { TranscodePreset } from '@app/infra/entities'; -import { Type } from 'class-transformer'; import { ApiProperty } from '@nestjs/swagger'; +import { Type } from 'class-transformer'; +import { IsBoolean, IsEnum, IsInt, IsString, Max, Min } from 'class-validator'; export class SystemConfigFFmpegDto { @IsInt() diff --git a/server/src/domain/system-config/dto/system-config.dto.ts b/server/src/domain/system-config/dto/system-config.dto.ts index a350a721aa..bd2fb5b5e3 100644 --- a/server/src/domain/system-config/dto/system-config.dto.ts +++ b/server/src/domain/system-config/dto/system-config.dto.ts @@ -1,8 +1,8 @@ import { SystemConfig } from '@app/infra/entities'; import { Type } from 'class-transformer'; import { IsObject, ValidateNested } from 'class-validator'; -import { SystemConfigJobDto } from './system-config-job.dto'; import { SystemConfigFFmpegDto } from './system-config-ffmpeg.dto'; +import { SystemConfigJobDto } from './system-config-job.dto'; import { SystemConfigOAuthDto } from './system-config-oauth.dto'; import { SystemConfigPasswordLoginDto } from './system-config-password-login.dto'; import { SystemConfigStorageTemplateDto } from './system-config-storage-template.dto'; diff --git a/server/src/domain/system-config/system-config.service.ts b/server/src/domain/system-config/system-config.service.ts index 426f5725f2..dcc3728ba5 100644 --- a/server/src/domain/system-config/system-config.service.ts +++ b/server/src/domain/system-config/system-config.service.ts @@ -1,4 +1,8 @@ +import { Inject, Injectable } from '@nestjs/common'; import { ISystemConfigRepository } from '.'; +import { IJobRepository, JobName } from '../job'; +import { mapConfig, SystemConfigDto } from './dto/system-config.dto'; +import { SystemConfigTemplateStorageOptionDto } from './response-dto/system-config-template-storage-option.dto'; import { supportedDayTokens, supportedHourTokens, @@ -8,10 +12,6 @@ import { supportedSecondTokens, supportedYearTokens, } from './system-config.constants'; -import { Inject, Injectable } from '@nestjs/common'; -import { IJobRepository, JobName } from '../job'; -import { mapConfig, SystemConfigDto } from './dto/system-config.dto'; -import { SystemConfigTemplateStorageOptionDto } from './response-dto/system-config-template-storage-option.dto'; import { SystemConfigCore, SystemConfigValidator } from './system-config.core'; @Injectable() diff --git a/server/src/domain/tag/tag.service.spec.ts b/server/src/domain/tag/tag.service.spec.ts index 8bed512d21..7b6b4f8638 100644 --- a/server/src/domain/tag/tag.service.spec.ts +++ b/server/src/domain/tag/tag.service.spec.ts @@ -1,7 +1,7 @@ import { TagType } from '@app/infra/entities'; import { BadRequestException } from '@nestjs/common'; -import { when } from 'jest-when'; import { assetEntityStub, authStub, newTagRepositoryMock, tagResponseStub, tagStub } from '@test'; +import { when } from 'jest-when'; import { AssetIdErrorReason } from '../asset'; import { ITagRepository } from './tag.repository'; import { TagService } from './tag.service'; diff --git a/server/src/domain/user-token/index.ts b/server/src/domain/user-token/index.ts index 46c83640c7..45d9ea9843 100644 --- a/server/src/domain/user-token/index.ts +++ b/server/src/domain/user-token/index.ts @@ -1,2 +1,2 @@ -export * from './user-token.repository'; export * from './user-token.core'; +export * from './user-token.repository'; diff --git a/server/src/domain/user/dto/create-user.dto.ts b/server/src/domain/user/dto/create-user.dto.ts index ef857ffe21..3927ffe2e6 100644 --- a/server/src/domain/user/dto/create-user.dto.ts +++ b/server/src/domain/user/dto/create-user.dto.ts @@ -1,6 +1,6 @@ +import { toEmail, toSanitized } from '@app/immich/utils/transform.util'; import { Transform } from 'class-transformer'; import { IsEmail, IsNotEmpty, IsOptional, IsString } from 'class-validator'; -import { toEmail, toSanitized } from '@app/immich/utils/transform.util'; export class CreateUserDto { @IsEmail({ require_tld: false }) diff --git a/server/src/domain/user/dto/update-user.dto.ts b/server/src/domain/user/dto/update-user.dto.ts index c17abcbdb0..14c16acf1b 100644 --- a/server/src/domain/user/dto/update-user.dto.ts +++ b/server/src/domain/user/dto/update-user.dto.ts @@ -1,7 +1,7 @@ +import { toEmail, toSanitized } from '@app/immich/utils/transform.util'; import { ApiProperty } from '@nestjs/swagger'; import { Transform } from 'class-transformer'; import { IsBoolean, IsEmail, IsNotEmpty, IsOptional, IsString, IsUUID } from 'class-validator'; -import { toEmail, toSanitized } from '@app/immich/utils/transform.util'; export class UpdateUserDto { @IsOptional() diff --git a/server/src/domain/user/user.service.spec.ts b/server/src/domain/user/user.service.spec.ts index 518873286d..d4229847dd 100644 --- a/server/src/domain/user/user.service.spec.ts +++ b/server/src/domain/user/user.service.spec.ts @@ -1,6 +1,5 @@ import { UserEntity } from '@app/infra/entities'; import { BadRequestException, ForbiddenException, NotFoundException } from '@nestjs/common'; -import { when } from 'jest-when'; import { newAlbumRepositoryMock, newAssetRepositoryMock, @@ -9,6 +8,7 @@ import { newStorageRepositoryMock, newUserRepositoryMock, } from '@test'; +import { when } from 'jest-when'; import { IAlbumRepository } from '../album'; import { IAssetRepository } from '../asset'; import { AuthUserDto } from '../auth'; diff --git a/server/src/domain/user/user.service.ts b/server/src/domain/user/user.service.ts index dfc818204c..d668151957 100644 --- a/server/src/domain/user/user.service.ts +++ b/server/src/domain/user/user.service.ts @@ -9,7 +9,6 @@ import { ICryptoRepository } from '../crypto/crypto.repository'; import { IEntityJob, IJobRepository, JobName } from '../job'; import { StorageCore, StorageFolder } from '../storage'; import { IStorageRepository } from '../storage/storage.repository'; -import { IUserRepository } from './user.repository'; import { CreateUserDto, UpdateUserDto, UserCountDto } from './dto'; import { CreateProfileImageResponseDto, @@ -20,6 +19,7 @@ import { UserResponseDto, } from './response-dto'; import { UserCore } from './user.core'; +import { IUserRepository } from './user.repository'; @Injectable() export class UserService { diff --git a/server/src/immich/api-v1/album/album.module.ts b/server/src/immich/api-v1/album/album.module.ts index ad13cdcf3e..3b09fd6ea8 100644 --- a/server/src/immich/api-v1/album/album.module.ts +++ b/server/src/immich/api-v1/album/album.module.ts @@ -1,10 +1,10 @@ -import { Module } from '@nestjs/common'; -import { AlbumService } from './album.service'; -import { AlbumController } from './album.controller'; -import { TypeOrmModule } from '@nestjs/typeorm'; import { AlbumEntity, AssetEntity } from '@app/infra/entities'; -import { AlbumRepository, IAlbumRepository } from './album-repository'; +import { Module } from '@nestjs/common'; +import { TypeOrmModule } from '@nestjs/typeorm'; import { DownloadModule } from '../../modules/download/download.module'; +import { AlbumRepository, IAlbumRepository } from './album-repository'; +import { AlbumController } from './album.controller'; +import { AlbumService } from './album.service'; @Module({ imports: [TypeOrmModule.forFeature([AlbumEntity, AssetEntity]), DownloadModule], diff --git a/server/src/immich/api-v1/album/album.service.ts b/server/src/immich/api-v1/album/album.service.ts index bda00573aa..75df03a13d 100644 --- a/server/src/immich/api-v1/album/album.service.ts +++ b/server/src/immich/api-v1/album/album.service.ts @@ -1,21 +1,22 @@ -import { BadRequestException, Inject, Injectable, NotFoundException, ForbiddenException, Logger } from '@nestjs/common'; -import { AuthUserDto } from '../../decorators/auth-user.decorator'; +import { + AlbumResponseDto, + ICryptoRepository, + ISharedLinkRepository, + mapAlbum, + mapSharedLink, + SharedLinkCore, + SharedLinkResponseDto, +} from '@app/domain'; import { AlbumEntity, SharedLinkType } from '@app/infra/entities'; -import { RemoveAssetsDto } from './dto/remove-assets.dto'; -import { AlbumResponseDto, mapAlbum } from '@app/domain'; -import { IAlbumRepository } from './album-repository'; -import { AddAssetsResponseDto } from './response-dto/add-assets-response.dto'; -import { AddAssetsDto } from './dto/add-assets.dto'; +import { BadRequestException, ForbiddenException, Inject, Injectable, Logger, NotFoundException } from '@nestjs/common'; +import { AuthUserDto } from '../../decorators/auth-user.decorator'; import { DownloadService } from '../../modules/download/download.service'; import { DownloadDto } from '../asset/dto/download-library.dto'; -import { - SharedLinkCore, - ISharedLinkRepository, - mapSharedLink, - SharedLinkResponseDto, - ICryptoRepository, -} from '@app/domain'; +import { IAlbumRepository } from './album-repository'; +import { AddAssetsDto } from './dto/add-assets.dto'; import { CreateAlbumShareLinkDto } from './dto/create-album-shared-link.dto'; +import { RemoveAssetsDto } from './dto/remove-assets.dto'; +import { AddAssetsResponseDto } from './response-dto/add-assets-response.dto'; @Injectable() export class AlbumService { diff --git a/server/src/immich/api-v1/album/dto/create-album-shared-link.dto.ts b/server/src/immich/api-v1/album/dto/create-album-shared-link.dto.ts index 284b6f741d..eedf7a2070 100644 --- a/server/src/immich/api-v1/album/dto/create-album-shared-link.dto.ts +++ b/server/src/immich/api-v1/album/dto/create-album-shared-link.dto.ts @@ -1,5 +1,5 @@ -import { ApiProperty } from '@nestjs/swagger'; import { ValidateUUID } from '@app/immich/decorators/validate-uuid.decorator'; +import { ApiProperty } from '@nestjs/swagger'; import { Type } from 'class-transformer'; import { IsBoolean, IsDate, IsOptional, IsString } from 'class-validator'; diff --git a/server/src/immich/api-v1/album/response-dto/add-assets-response.dto.ts b/server/src/immich/api-v1/album/response-dto/add-assets-response.dto.ts index 5072621625..2580d5478e 100644 --- a/server/src/immich/api-v1/album/response-dto/add-assets-response.dto.ts +++ b/server/src/immich/api-v1/album/response-dto/add-assets-response.dto.ts @@ -1,5 +1,5 @@ -import { ApiProperty } from '@nestjs/swagger'; import { AlbumResponseDto } from '@app/domain'; +import { ApiProperty } from '@nestjs/swagger'; export class AddAssetsResponseDto { @ApiProperty({ type: 'integer' }) diff --git a/server/src/immich/api-v1/asset/asset-repository.ts b/server/src/immich/api-v1/asset/asset-repository.ts index e896e196de..ec3e39cf88 100644 --- a/server/src/immich/api-v1/asset/asset-repository.ts +++ b/server/src/immich/api-v1/asset/asset-repository.ts @@ -1,19 +1,19 @@ -import { SearchPropertiesDto } from './dto/search-properties.dto'; -import { CuratedLocationsResponseDto } from './response-dto/curated-locations-response.dto'; import { AssetEntity, AssetType, ExifEntity } from '@app/infra/entities'; import { Injectable } from '@nestjs/common'; import { InjectRepository } from '@nestjs/typeorm'; -import { Repository } from 'typeorm/repository/Repository'; -import { CuratedObjectsResponseDto } from './response-dto/curated-objects-response.dto'; -import { AssetCountByTimeBucket } from './response-dto/asset-count-by-time-group-response.dto'; -import { GetAssetCountByTimeBucketDto, TimeGroupEnum } from './dto/get-asset-count-by-time-bucket.dto'; -import { GetAssetByTimeBucketDto } from './dto/get-asset-by-time-bucket.dto'; -import { AssetCountByUserIdResponseDto } from './response-dto/asset-count-by-user-id-response.dto'; -import { CheckExistingAssetsDto } from './dto/check-existing-assets.dto'; -import { In } from 'typeorm/find-options/operator/In'; -import { UpdateAssetDto } from './dto/update-asset.dto'; import { IsNull, Not } from 'typeorm'; +import { In } from 'typeorm/find-options/operator/In'; +import { Repository } from 'typeorm/repository/Repository'; import { AssetSearchDto } from './dto/asset-search.dto'; +import { CheckExistingAssetsDto } from './dto/check-existing-assets.dto'; +import { GetAssetByTimeBucketDto } from './dto/get-asset-by-time-bucket.dto'; +import { GetAssetCountByTimeBucketDto, TimeGroupEnum } from './dto/get-asset-count-by-time-bucket.dto'; +import { SearchPropertiesDto } from './dto/search-properties.dto'; +import { UpdateAssetDto } from './dto/update-asset.dto'; +import { AssetCountByTimeBucket } from './response-dto/asset-count-by-time-group-response.dto'; +import { AssetCountByUserIdResponseDto } from './response-dto/asset-count-by-user-id-response.dto'; +import { CuratedLocationsResponseDto } from './response-dto/curated-locations-response.dto'; +import { CuratedObjectsResponseDto } from './response-dto/curated-objects-response.dto'; export interface AssetCheck { id: string; diff --git a/server/src/immich/api-v1/asset/asset.controller.ts b/server/src/immich/api-v1/asset/asset.controller.ts index e2dbb49693..270f826a4e 100644 --- a/server/src/immich/api-v1/asset/asset.controller.ts +++ b/server/src/immich/api-v1/asset/asset.controller.ts @@ -1,62 +1,61 @@ -import { AddAssetsDto } from '../album/dto/add-assets.dto'; +import { AssetResponseDto, ImmichReadStream, SharedLinkResponseDto } from '@app/domain'; import { - Controller, - Post, - UseInterceptors, Body, + Controller, + Delete, Get, + Header, + Headers, + HttpCode, Param, - ValidationPipe, + ParseFilePipe, + Patch, + Post, + Put, Query, Response, - Headers, - Delete, - HttpCode, - Header, - Put, - UploadedFiles, - Patch, StreamableFile, - ParseFilePipe, + UploadedFiles, + UseInterceptors, + ValidationPipe, } from '@nestjs/common'; -import { Authenticated, SharedLinkRoute } from '../../decorators/authenticated.decorator'; -import { AssetService } from './asset.service'; import { FileFieldsInterceptor } from '@nestjs/platform-express'; -import { AuthUserDto, AuthUser } from '../../decorators/auth-user.decorator'; -import { ServeFileDto } from './dto/serve-file.dto'; -import { Response as Res } from 'express'; -import { DeleteAssetDto } from './dto/delete-asset.dto'; -import { SearchAssetDto } from './dto/search-asset.dto'; -import { CheckDuplicateAssetDto } from './dto/check-duplicate-asset.dto'; import { ApiBody, ApiConsumes, ApiHeader, ApiOkResponse, ApiTags } from '@nestjs/swagger'; -import { CuratedObjectsResponseDto } from './response-dto/curated-objects-response.dto'; -import { CuratedLocationsResponseDto } from './response-dto/curated-locations-response.dto'; -import { AssetResponseDto, ImmichReadStream } from '@app/domain'; -import { CheckDuplicateAssetResponseDto } from './response-dto/check-duplicate-asset-response.dto'; -import { CreateAssetDto, mapToUploadFile } from './dto/create-asset.dto'; -import { AssetFileUploadResponseDto } from './response-dto/asset-file-upload-response.dto'; -import { DeleteAssetResponseDto } from './response-dto/delete-asset-response.dto'; -import { GetAssetThumbnailDto } from './dto/get-asset-thumbnail.dto'; -import { AssetCountByTimeBucketResponseDto } from './response-dto/asset-count-by-time-group-response.dto'; -import { GetAssetCountByTimeBucketDto } from './dto/get-asset-count-by-time-bucket.dto'; -import { GetAssetByTimeBucketDto } from './dto/get-asset-by-time-bucket.dto'; -import { AssetCountByUserIdResponseDto } from './response-dto/asset-count-by-user-id-response.dto'; -import { CheckExistingAssetsDto } from './dto/check-existing-assets.dto'; -import { CheckExistingAssetsResponseDto } from './response-dto/check-existing-assets-response.dto'; -import { UpdateAssetDto } from './dto/update-asset.dto'; -import { DownloadDto } from './dto/download-library.dto'; -import { DownloadFilesDto } from './dto/download-files.dto'; -import { CreateAssetsShareLinkDto } from './dto/create-asset-shared-link.dto'; -import { SharedLinkResponseDto } from '@app/domain'; -import { AssetSearchDto } from './dto/asset-search.dto'; -import { assetUploadOption, ImmichFile } from '../../config/asset-upload.config'; -import FileNotEmptyValidator from '../validation/file-not-empty-validator'; -import { RemoveAssetsDto } from '../album/dto/remove-assets.dto'; -import { AssetBulkUploadCheckDto } from './dto/asset-check.dto'; -import { AssetBulkUploadCheckResponseDto } from './response-dto/asset-check-response.dto'; -import { UUIDParamDto } from '../../controllers/dto/uuid-param.dto'; -import { DeviceIdDto } from './dto/device-id.dto'; +import { Response as Res } from 'express'; import { handleDownload } from '../../app.utils'; +import { assetUploadOption, ImmichFile } from '../../config/asset-upload.config'; +import { UUIDParamDto } from '../../controllers/dto/uuid-param.dto'; +import { AuthUser, AuthUserDto } from '../../decorators/auth-user.decorator'; +import { Authenticated, SharedLinkRoute } from '../../decorators/authenticated.decorator'; +import { AddAssetsDto } from '../album/dto/add-assets.dto'; +import { RemoveAssetsDto } from '../album/dto/remove-assets.dto'; +import FileNotEmptyValidator from '../validation/file-not-empty-validator'; +import { AssetService } from './asset.service'; +import { AssetBulkUploadCheckDto } from './dto/asset-check.dto'; +import { AssetSearchDto } from './dto/asset-search.dto'; +import { CheckDuplicateAssetDto } from './dto/check-duplicate-asset.dto'; +import { CheckExistingAssetsDto } from './dto/check-existing-assets.dto'; +import { CreateAssetsShareLinkDto } from './dto/create-asset-shared-link.dto'; +import { CreateAssetDto, mapToUploadFile } from './dto/create-asset.dto'; +import { DeleteAssetDto } from './dto/delete-asset.dto'; +import { DeviceIdDto } from './dto/device-id.dto'; +import { DownloadFilesDto } from './dto/download-files.dto'; +import { DownloadDto } from './dto/download-library.dto'; +import { GetAssetByTimeBucketDto } from './dto/get-asset-by-time-bucket.dto'; +import { GetAssetCountByTimeBucketDto } from './dto/get-asset-count-by-time-bucket.dto'; +import { GetAssetThumbnailDto } from './dto/get-asset-thumbnail.dto'; +import { SearchAssetDto } from './dto/search-asset.dto'; +import { ServeFileDto } from './dto/serve-file.dto'; +import { UpdateAssetDto } from './dto/update-asset.dto'; +import { AssetBulkUploadCheckResponseDto } from './response-dto/asset-check-response.dto'; +import { AssetCountByTimeBucketResponseDto } from './response-dto/asset-count-by-time-group-response.dto'; +import { AssetCountByUserIdResponseDto } from './response-dto/asset-count-by-user-id-response.dto'; +import { AssetFileUploadResponseDto } from './response-dto/asset-file-upload-response.dto'; +import { CheckDuplicateAssetResponseDto } from './response-dto/check-duplicate-asset-response.dto'; +import { CheckExistingAssetsResponseDto } from './response-dto/check-existing-assets-response.dto'; +import { CuratedLocationsResponseDto } from './response-dto/curated-locations-response.dto'; +import { CuratedObjectsResponseDto } from './response-dto/curated-objects-response.dto'; +import { DeleteAssetResponseDto } from './response-dto/delete-asset-response.dto'; function asStreamableFile({ stream, type, length }: ImmichReadStream) { return new StreamableFile(stream, { type, length }); diff --git a/server/src/immich/api-v1/asset/asset.core.ts b/server/src/immich/api-v1/asset/asset.core.ts index 8b9d868034..d0f48657a5 100644 --- a/server/src/immich/api-v1/asset/asset.core.ts +++ b/server/src/immich/api-v1/asset/asset.core.ts @@ -1,8 +1,8 @@ import { AuthUserDto, IJobRepository, JobName } from '@app/domain'; import { AssetEntity, AssetType, UserEntity } from '@app/infra/entities'; +import { parse } from 'node:path'; import { IAssetRepository } from './asset-repository'; import { CreateAssetDto, UploadFile } from './dto/create-asset.dto'; -import { parse } from 'node:path'; export class AssetCore { constructor(private repository: IAssetRepository, private jobRepository: IJobRepository) {} diff --git a/server/src/immich/api-v1/asset/asset.module.ts b/server/src/immich/api-v1/asset/asset.module.ts index 5dcadc52ee..1f633d9554 100644 --- a/server/src/immich/api-v1/asset/asset.module.ts +++ b/server/src/immich/api-v1/asset/asset.module.ts @@ -1,10 +1,10 @@ -import { Module } from '@nestjs/common'; -import { AssetService } from './asset.service'; -import { AssetController } from './asset.controller'; -import { TypeOrmModule } from '@nestjs/typeorm'; import { AssetEntity, ExifEntity } from '@app/infra/entities'; -import { AssetRepository, IAssetRepository } from './asset-repository'; +import { Module } from '@nestjs/common'; +import { TypeOrmModule } from '@nestjs/typeorm'; import { DownloadModule } from '../../modules/download/download.module'; +import { AssetRepository, IAssetRepository } from './asset-repository'; +import { AssetController } from './asset.controller'; +import { AssetService } from './asset.service'; @Module({ imports: [ diff --git a/server/src/immich/api-v1/asset/asset.service.spec.ts b/server/src/immich/api-v1/asset/asset.service.spec.ts index 670c58f0db..fcd739c9a9 100644 --- a/server/src/immich/api-v1/asset/asset.service.spec.ts +++ b/server/src/immich/api-v1/asset/asset.service.spec.ts @@ -1,12 +1,3 @@ -import { IAssetRepository } from './asset-repository'; -import { AssetService } from './asset.service'; -import { QueryFailedError, Repository } from 'typeorm'; -import { AssetEntity, AssetType, ExifEntity } from '@app/infra/entities'; -import { CreateAssetDto } from './dto/create-asset.dto'; -import { AssetCountByTimeBucket } from './response-dto/asset-count-by-time-group-response.dto'; -import { TimeGroupEnum } from './dto/get-asset-count-by-time-bucket.dto'; -import { AssetCountByUserIdResponseDto } from './response-dto/asset-count-by-user-id-response.dto'; -import { DownloadService } from '../../modules/download/download.service'; import { IAccessRepository, ICryptoRepository, @@ -15,6 +6,8 @@ import { IStorageRepository, JobName, } from '@app/domain'; +import { AssetEntity, AssetType, ExifEntity } from '@app/infra/entities'; +import { BadRequestException, ForbiddenException } from '@nestjs/common'; import { assetEntityStub, authStub, @@ -27,10 +20,17 @@ import { sharedLinkResponseStub, sharedLinkStub, } from '@test'; -import { CreateAssetsShareLinkDto } from './dto/create-asset-shared-link.dto'; -import { BadRequestException, ForbiddenException } from '@nestjs/common'; import { when } from 'jest-when'; +import { QueryFailedError, Repository } from 'typeorm'; +import { DownloadService } from '../../modules/download/download.service'; +import { IAssetRepository } from './asset-repository'; +import { AssetService } from './asset.service'; +import { CreateAssetsShareLinkDto } from './dto/create-asset-shared-link.dto'; +import { CreateAssetDto } from './dto/create-asset.dto'; +import { TimeGroupEnum } from './dto/get-asset-count-by-time-bucket.dto'; import { AssetRejectReason, AssetUploadAction } from './response-dto/asset-check-response.dto'; +import { AssetCountByTimeBucket } from './response-dto/asset-count-by-time-group-response.dto'; +import { AssetCountByUserIdResponseDto } from './response-dto/asset-count-by-user-id-response.dto'; const _getCreateAssetDto = (): CreateAssetDto => { const createAssetDto = new CreateAssetDto(); diff --git a/server/src/immich/api-v1/asset/asset.service.ts b/server/src/immich/api-v1/asset/asset.service.ts index 6305a48f31..53d8922c7b 100644 --- a/server/src/immich/api-v1/asset/asset.service.ts +++ b/server/src/immich/api-v1/asset/asset.service.ts @@ -1,4 +1,20 @@ -import { CuratedLocationsResponseDto } from './response-dto/curated-locations-response.dto'; +import { + AssetResponseDto, + getLivePhotoMotionFilename, + IAccessRepository, + ICryptoRepository, + IJobRepository, + ImmichReadStream, + ISharedLinkRepository, + IStorageRepository, + JobName, + mapAsset, + mapAssetWithoutExif, + mapSharedLink, + SharedLinkCore, + SharedLinkResponseDto, +} from '@app/domain'; +import { AssetEntity, AssetType, SharedLinkType } from '@app/infra/entities'; import { BadRequestException, ForbiddenException, @@ -10,63 +26,49 @@ import { StreamableFile, } from '@nestjs/common'; import { InjectRepository } from '@nestjs/typeorm'; -import { QueryFailedError, Repository } from 'typeorm'; -import { AuthUserDto } from '../../decorators/auth-user.decorator'; -import { AssetEntity, AssetType, SharedLinkType } from '@app/infra/entities'; -import { constants, createReadStream, stat } from 'fs'; -import { ServeFileDto } from './dto/serve-file.dto'; import { Response as Res } from 'express'; -import { promisify } from 'util'; -import { DeleteAssetDto } from './dto/delete-asset.dto'; -import { SearchAssetDto } from './dto/search-asset.dto'; +import { constants, createReadStream, stat } from 'fs'; import fs from 'fs/promises'; -import { CheckDuplicateAssetDto } from './dto/check-duplicate-asset.dto'; -import { CuratedObjectsResponseDto } from './response-dto/curated-objects-response.dto'; -import { - AssetResponseDto, - getLivePhotoMotionFilename, - IAccessRepository, - ImmichReadStream, - IStorageRepository, - JobName, - mapAsset, - mapAssetWithoutExif, -} from '@app/domain'; -import { CreateAssetDto, UploadFile } from './dto/create-asset.dto'; -import { DeleteAssetResponseDto, DeleteAssetStatusEnum } from './response-dto/delete-asset-response.dto'; -import { GetAssetThumbnailDto, GetAssetThumbnailFormatEnum } from './dto/get-asset-thumbnail.dto'; -import { CheckDuplicateAssetResponseDto } from './response-dto/check-duplicate-asset-response.dto'; +import { QueryFailedError, Repository } from 'typeorm'; +import { promisify } from 'util'; +import { AuthUserDto } from '../../decorators/auth-user.decorator'; +import { DownloadService } from '../../modules/download/download.service'; +import { AddAssetsDto } from '../album/dto/add-assets.dto'; +import { RemoveAssetsDto } from '../album/dto/remove-assets.dto'; import { IAssetRepository } from './asset-repository'; +import { AssetCore } from './asset.core'; +import { AssetBulkUploadCheckDto } from './dto/asset-check.dto'; +import { AssetSearchDto } from './dto/asset-search.dto'; +import { CheckDuplicateAssetDto } from './dto/check-duplicate-asset.dto'; +import { CheckExistingAssetsDto } from './dto/check-existing-assets.dto'; +import { CreateAssetsShareLinkDto } from './dto/create-asset-shared-link.dto'; +import { CreateAssetDto, UploadFile } from './dto/create-asset.dto'; +import { DeleteAssetDto } from './dto/delete-asset.dto'; +import { DownloadFilesDto } from './dto/download-files.dto'; +import { DownloadDto } from './dto/download-library.dto'; +import { GetAssetByTimeBucketDto } from './dto/get-asset-by-time-bucket.dto'; +import { GetAssetCountByTimeBucketDto } from './dto/get-asset-count-by-time-bucket.dto'; +import { GetAssetThumbnailDto, GetAssetThumbnailFormatEnum } from './dto/get-asset-thumbnail.dto'; +import { SearchAssetDto } from './dto/search-asset.dto'; import { SearchPropertiesDto } from './dto/search-properties.dto'; +import { ServeFileDto } from './dto/serve-file.dto'; +import { UpdateAssetDto } from './dto/update-asset.dto'; +import { + AssetBulkUploadCheckResponseDto, + AssetRejectReason, + AssetUploadAction, +} from './response-dto/asset-check-response.dto'; import { AssetCountByTimeBucketResponseDto, mapAssetCountByTimeBucket, } from './response-dto/asset-count-by-time-group-response.dto'; -import { GetAssetCountByTimeBucketDto } from './dto/get-asset-count-by-time-bucket.dto'; -import { GetAssetByTimeBucketDto } from './dto/get-asset-by-time-bucket.dto'; import { AssetCountByUserIdResponseDto } from './response-dto/asset-count-by-user-id-response.dto'; -import { AssetCore } from './asset.core'; -import { CheckExistingAssetsDto } from './dto/check-existing-assets.dto'; -import { CheckExistingAssetsResponseDto } from './response-dto/check-existing-assets-response.dto'; -import { UpdateAssetDto } from './dto/update-asset.dto'; import { AssetFileUploadResponseDto } from './response-dto/asset-file-upload-response.dto'; -import { ICryptoRepository, IJobRepository } from '@app/domain'; -import { DownloadService } from '../../modules/download/download.service'; -import { DownloadDto } from './dto/download-library.dto'; -import { SharedLinkCore } from '@app/domain'; -import { ISharedLinkRepository } from '@app/domain'; -import { DownloadFilesDto } from './dto/download-files.dto'; -import { CreateAssetsShareLinkDto } from './dto/create-asset-shared-link.dto'; -import { mapSharedLink, SharedLinkResponseDto } from '@app/domain'; -import { AssetSearchDto } from './dto/asset-search.dto'; -import { AddAssetsDto } from '../album/dto/add-assets.dto'; -import { RemoveAssetsDto } from '../album/dto/remove-assets.dto'; -import { AssetBulkUploadCheckDto } from './dto/asset-check.dto'; -import { - AssetUploadAction, - AssetRejectReason, - AssetBulkUploadCheckResponseDto, -} from './response-dto/asset-check-response.dto'; +import { CheckDuplicateAssetResponseDto } from './response-dto/check-duplicate-asset-response.dto'; +import { CheckExistingAssetsResponseDto } from './response-dto/check-existing-assets-response.dto'; +import { CuratedLocationsResponseDto } from './response-dto/curated-locations-response.dto'; +import { CuratedObjectsResponseDto } from './response-dto/curated-objects-response.dto'; +import { DeleteAssetResponseDto, DeleteAssetStatusEnum } from './response-dto/delete-asset-response.dto'; const fileInfo = promisify(stat); diff --git a/server/src/immich/api-v1/validation/parse-me-uuid-pipe.ts b/server/src/immich/api-v1/validation/parse-me-uuid-pipe.ts index b4e598867c..4329af0112 100644 --- a/server/src/immich/api-v1/validation/parse-me-uuid-pipe.ts +++ b/server/src/immich/api-v1/validation/parse-me-uuid-pipe.ts @@ -1,4 +1,4 @@ -import { ParseUUIDPipe, Injectable, ArgumentMetadata } from '@nestjs/common'; +import { ArgumentMetadata, Injectable, ParseUUIDPipe } from '@nestjs/common'; @Injectable() export class ParseMeUUIDPipe extends ParseUUIDPipe { diff --git a/server/src/immich/controllers/app.controller.ts b/server/src/immich/controllers/app.controller.ts index 04c6aaeb26..9764ceb141 100644 --- a/server/src/immich/controllers/app.controller.ts +++ b/server/src/immich/controllers/app.controller.ts @@ -1,6 +1,6 @@ +import { SystemConfigService } from '@app/domain'; import { Controller, HttpCode, HttpStatus, Post } from '@nestjs/common'; import { ApiExcludeEndpoint } from '@nestjs/swagger'; -import { SystemConfigService } from '@app/domain'; @Controller() export class AppController { diff --git a/server/src/immich/controllers/asset.controller.ts b/server/src/immich/controllers/asset.controller.ts index 253e20e379..c6dbd22184 100644 --- a/server/src/immich/controllers/asset.controller.ts +++ b/server/src/immich/controllers/asset.controller.ts @@ -1,11 +1,11 @@ import { AssetService, AuthUserDto, MapMarkerResponseDto, MemoryLaneDto } from '@app/domain'; import { MapMarkerDto } from '@app/domain/asset/dto/map-marker.dto'; +import { MemoryLaneResponseDto } from '@app/domain/asset/response-dto/memory-lane-response.dto'; import { Controller, Get, Query } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; import { AuthUser } from '../decorators/auth-user.decorator'; import { Authenticated } from '../decorators/authenticated.decorator'; import { UseValidation } from '../decorators/use-validation.decorator'; -import { MemoryLaneResponseDto } from '@app/domain/asset/response-dto/memory-lane-response.dto'; @ApiTags('Asset') @Controller('asset') diff --git a/server/src/immich/controllers/job.controller.ts b/server/src/immich/controllers/job.controller.ts index c4d88c6c02..7f26f5834f 100644 --- a/server/src/immich/controllers/job.controller.ts +++ b/server/src/immich/controllers/job.controller.ts @@ -1,4 +1,4 @@ -import { AllJobStatusResponseDto, JobCommandDto, JobStatusDto, JobIdDto, JobService } from '@app/domain'; +import { AllJobStatusResponseDto, JobCommandDto, JobIdDto, JobService, JobStatusDto } from '@app/domain'; import { Body, Controller, Get, Param, Put } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; import { Authenticated } from '../decorators/authenticated.decorator'; diff --git a/server/src/immich/controllers/partner.controller.ts b/server/src/immich/controllers/partner.controller.ts index 49677f2da0..06fa506b99 100644 --- a/server/src/immich/controllers/partner.controller.ts +++ b/server/src/immich/controllers/partner.controller.ts @@ -1,7 +1,7 @@ import { PartnerDirection, PartnerService, UserResponseDto } from '@app/domain'; import { Controller, Delete, Get, Param, Post, Query } from '@nestjs/common'; import { ApiQuery, ApiTags } from '@nestjs/swagger'; -import { AuthUserDto, AuthUser } from '../decorators/auth-user.decorator'; +import { AuthUser, AuthUserDto } from '../decorators/auth-user.decorator'; import { Authenticated } from '../decorators/authenticated.decorator'; import { UseValidation } from '../decorators/use-validation.decorator'; import { UUIDParamDto } from './dto/uuid-param.dto'; diff --git a/server/src/immich/controllers/tag.controller.ts b/server/src/immich/controllers/tag.controller.ts index d4e7a8d28e..7d23e2bf77 100644 --- a/server/src/immich/controllers/tag.controller.ts +++ b/server/src/immich/controllers/tag.controller.ts @@ -9,7 +9,7 @@ import { } from '@app/domain'; import { Body, Controller, Delete, Get, Param, Patch, Post, Put } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; -import { AuthUserDto, AuthUser } from '../decorators/auth-user.decorator'; +import { AuthUser, AuthUserDto } from '../decorators/auth-user.decorator'; import { Authenticated } from '../decorators/authenticated.decorator'; import { UseValidation } from '../decorators/use-validation.decorator'; import { UUIDParamDto } from './dto/uuid-param.dto'; diff --git a/server/src/immich/controllers/user.controller.ts b/server/src/immich/controllers/user.controller.ts index 41e9c06419..b96d4bf39c 100644 --- a/server/src/immich/controllers/user.controller.ts +++ b/server/src/immich/controllers/user.controller.ts @@ -1,34 +1,36 @@ import { - Controller, - Get, - Post, - Delete, + CreateProfileImageDto, + CreateProfileImageResponseDto, + CreateUserDto, + UpdateUserDto, + UserCountDto, + UserCountResponseDto, + UserResponseDto, + UserService, +} from '@app/domain'; +import { UserIdDto } from '@app/domain/user/dto/user-id.dto'; +import { Body, + Controller, + Delete, + Get, + Header, Param, + Post, Put, Query, - UseInterceptors, - UploadedFile, Response, StreamableFile, - Header, + UploadedFile, + UseInterceptors, } from '@nestjs/common'; -import { UserService } from '@app/domain'; -import { AdminRoute, Authenticated, PublicRoute } from '../decorators/authenticated.decorator'; -import { AuthUserDto, AuthUser } from '../decorators/auth-user.decorator'; -import { CreateUserDto } from '@app/domain'; -import { UpdateUserDto } from '@app/domain'; import { FileInterceptor } from '@nestjs/platform-express'; -import { profileImageUploadOption } from '../config/profile-image-upload.config'; -import { Response as Res } from 'express'; import { ApiBody, ApiConsumes, ApiTags } from '@nestjs/swagger'; -import { UserResponseDto } from '@app/domain'; -import { UserCountResponseDto } from '@app/domain'; -import { CreateProfileImageDto } from '@app/domain'; -import { CreateProfileImageResponseDto } from '@app/domain'; -import { UserCountDto } from '@app/domain'; +import { Response as Res } from 'express'; +import { profileImageUploadOption } from '../config/profile-image-upload.config'; +import { AuthUser, AuthUserDto } from '../decorators/auth-user.decorator'; +import { AdminRoute, Authenticated, PublicRoute } from '../decorators/authenticated.decorator'; import { UseValidation } from '../decorators/use-validation.decorator'; -import { UserIdDto } from '@app/domain/user/dto/user-id.dto'; @ApiTags('User') @Controller('user') diff --git a/server/src/immich/modules/download/download.service.ts b/server/src/immich/modules/download/download.service.ts index c11377407c..65a460278c 100644 --- a/server/src/immich/modules/download/download.service.ts +++ b/server/src/immich/modules/download/download.service.ts @@ -1,8 +1,8 @@ +import { asHumanReadable, HumanReadableSize } from '@app/domain'; import { AssetEntity } from '@app/infra/entities'; import { BadRequestException, Injectable, InternalServerErrorException, Logger, StreamableFile } from '@nestjs/common'; import archiver from 'archiver'; import { extname } from 'path'; -import { asHumanReadable, HumanReadableSize } from '@app/domain'; export interface DownloadArchive { stream: StreamableFile; diff --git a/server/src/infra/communication.gateway.ts b/server/src/infra/communication.gateway.ts index 758b1a8b71..483f9d9d7c 100644 --- a/server/src/infra/communication.gateway.ts +++ b/server/src/infra/communication.gateway.ts @@ -1,7 +1,7 @@ +import { AuthService } from '@app/domain'; import { Logger } from '@nestjs/common'; import { OnGatewayConnection, OnGatewayDisconnect, WebSocketGateway, WebSocketServer } from '@nestjs/websockets'; import { Server, Socket } from 'socket.io'; -import { AuthService } from '@app/domain'; @WebSocketGateway({ cors: true }) export class CommunicationGateway implements OnGatewayConnection, OnGatewayDisconnect { diff --git a/server/src/infra/entities/album.entity.ts b/server/src/infra/entities/album.entity.ts index 6dd4b92740..5cf2ebd31e 100644 --- a/server/src/infra/entities/album.entity.ts +++ b/server/src/infra/entities/album.entity.ts @@ -9,8 +9,8 @@ import { PrimaryGeneratedColumn, UpdateDateColumn, } from 'typeorm'; -import { SharedLinkEntity } from './shared-link.entity'; import { AssetEntity } from './asset.entity'; +import { SharedLinkEntity } from './shared-link.entity'; import { UserEntity } from './user.entity'; @Entity('albums') diff --git a/server/src/infra/entities/partner.entity.ts b/server/src/infra/entities/partner.entity.ts index f22eebf298..d7be830828 100644 --- a/server/src/infra/entities/partner.entity.ts +++ b/server/src/infra/entities/partner.entity.ts @@ -1,4 +1,4 @@ -import { CreateDateColumn, Entity, ManyToOne, PrimaryColumn, JoinColumn, UpdateDateColumn } from 'typeorm'; +import { CreateDateColumn, Entity, JoinColumn, ManyToOne, PrimaryColumn, UpdateDateColumn } from 'typeorm'; import { UserEntity } from './user.entity'; diff --git a/server/src/infra/entities/system-config.entity.ts b/server/src/infra/entities/system-config.entity.ts index 0bcb4cf4e5..8d2a5c5b5c 100644 --- a/server/src/infra/entities/system-config.entity.ts +++ b/server/src/infra/entities/system-config.entity.ts @@ -1,5 +1,5 @@ -import { Column, Entity, PrimaryColumn } from 'typeorm'; import { QueueName } from '@app/domain/job/job.constants'; +import { Column, Entity, PrimaryColumn } from 'typeorm'; @Entity('system_config') export class SystemConfigEntity { diff --git a/server/src/infra/redis-io.adapter.ts b/server/src/infra/redis-io.adapter.ts index ac03408d9f..dbf99dd411 100644 --- a/server/src/infra/redis-io.adapter.ts +++ b/server/src/infra/redis-io.adapter.ts @@ -1,7 +1,7 @@ +import { Logger } from '@nestjs/common'; import { IoAdapter } from '@nestjs/platform-socket.io'; import { createAdapter } from '@socket.io/redis-adapter'; import Redis from 'ioredis'; -import { Logger } from '@nestjs/common'; import { ServerOptions } from 'socket.io'; import { redisConfig } from './infra.config'; diff --git a/server/src/infra/repositories/crypto.repository.ts b/server/src/infra/repositories/crypto.repository.ts index 59c7c310ef..6ded5b0201 100644 --- a/server/src/infra/repositories/crypto.repository.ts +++ b/server/src/infra/repositories/crypto.repository.ts @@ -1,7 +1,7 @@ import { ICryptoRepository } from '@app/domain'; import { Injectable } from '@nestjs/common'; import { compareSync, hash } from 'bcrypt'; -import { randomBytes, createHash } from 'crypto'; +import { createHash, randomBytes } from 'crypto'; @Injectable() export class CryptoRepository implements ICryptoRepository { diff --git a/server/src/infra/repositories/media.repository.ts b/server/src/infra/repositories/media.repository.ts index c7340d6055..e404a026f7 100644 --- a/server/src/infra/repositories/media.repository.ts +++ b/server/src/infra/repositories/media.repository.ts @@ -1,8 +1,8 @@ import { CropOptions, IMediaRepository, ResizeOptions, TranscodeOptions, VideoInfo } from '@app/domain'; import ffmpeg, { FfprobeData } from 'fluent-ffmpeg'; +import fs from 'fs/promises'; import sharp from 'sharp'; import { promisify } from 'util'; -import fs from 'fs/promises'; const probe = promisify(ffmpeg.ffprobe); diff --git a/server/src/infra/repositories/user-token.repository.ts b/server/src/infra/repositories/user-token.repository.ts index 9469aa1bb1..685a5983b9 100644 --- a/server/src/infra/repositories/user-token.repository.ts +++ b/server/src/infra/repositories/user-token.repository.ts @@ -1,8 +1,8 @@ +import { IUserTokenRepository } from '@app/domain/user-token'; import { Injectable } from '@nestjs/common'; import { InjectRepository } from '@nestjs/typeorm'; import { Repository } from 'typeorm'; import { UserTokenEntity } from '../entities'; -import { IUserTokenRepository } from '@app/domain/user-token'; @Injectable() export class UserTokenRepository implements IUserTokenRepository { diff --git a/server/src/main.ts b/server/src/main.ts index f5e83aacff..3ab308fd51 100644 --- a/server/src/main.ts +++ b/server/src/main.ts @@ -1,6 +1,6 @@ +import { bootstrap as cli } from './cli/immich'; import { bootstrap as immich } from './immich/main'; import { bootstrap as microservices } from './microservices/main'; -import { bootstrap as cli } from './cli/immich'; const immichApp = process.argv[2] || process.env.IMMICH_APP; diff --git a/server/src/microservices/utils/exif/coordinates.spec.ts b/server/src/microservices/utils/exif/coordinates.spec.ts index 8fd598f60c..975d1e9969 100644 --- a/server/src/microservices/utils/exif/coordinates.spec.ts +++ b/server/src/microservices/utils/exif/coordinates.spec.ts @@ -1,4 +1,4 @@ -import { describe, it, expect } from '@jest/globals'; +import { describe, expect, it } from '@jest/globals'; import { parseLatitude, parseLongitude } from './coordinates'; describe('parsing latitude from string input', () => { diff --git a/server/src/microservices/utils/exif/iso.spec.ts b/server/src/microservices/utils/exif/iso.spec.ts index 0dae44e15f..4a5343729f 100644 --- a/server/src/microservices/utils/exif/iso.spec.ts +++ b/server/src/microservices/utils/exif/iso.spec.ts @@ -1,4 +1,4 @@ -import { describe, it, expect } from '@jest/globals'; +import { describe, expect, it } from '@jest/globals'; import { parseISO } from './iso'; describe('parsing ISO values', () => { diff --git a/server/src/microservices/utils/numbers.spec.ts b/server/src/microservices/utils/numbers.spec.ts index 44bf59ad43..0f26566df2 100644 --- a/server/src/microservices/utils/numbers.spec.ts +++ b/server/src/microservices/utils/numbers.spec.ts @@ -1,4 +1,4 @@ -import { describe, it, expect } from '@jest/globals'; +import { describe, expect, it } from '@jest/globals'; import { isDecimalNumber, isNumberInRange, toNumberOrNull } from './numbers'; describe('checks if a number is a decimal number', () => { diff --git a/server/test/fixtures.ts b/server/test/fixtures.ts index 0fa4cfd8af..eaa22a466d 100644 --- a/server/test/fixtures.ts +++ b/server/test/fixtures.ts @@ -1,3 +1,18 @@ +import { + AlbumResponseDto, + AssetResponseDto, + AudioStreamInfo, + AuthUserDto, + ExifResponseDto, + mapUser, + QueueName, + SearchResult, + SharedLinkResponseDto, + TagResponseDto, + VideoFormat, + VideoInfo, + VideoStreamInfo, +} from '@app/domain'; import { AlbumEntity, APIKeyEntity, @@ -16,21 +31,6 @@ import { UserEntity, UserTokenEntity, } from '@app/infra/entities'; -import { - AlbumResponseDto, - AssetResponseDto, - AudioStreamInfo, - AuthUserDto, - ExifResponseDto, - mapUser, - QueueName, - SearchResult, - SharedLinkResponseDto, - TagResponseDto, - VideoFormat, - VideoInfo, - VideoStreamInfo, -} from '@app/domain'; const today = new Date(); const tomorrow = new Date(); diff --git a/server/test/index.ts b/server/test/index.ts index 176dc87cab..c63f82dca4 100644 --- a/server/test/index.ts +++ b/server/test/index.ts @@ -1,5 +1,5 @@ -export * from './repositories'; export * from './fixtures'; +export * from './repositories'; export async function asyncTick(steps: number) { for (let i = 0; i < steps; i++) { diff --git a/server/test/test-utils.ts b/server/test/test-utils.ts index 708c4eedee..5736a20775 100644 --- a/server/test/test-utils.ts +++ b/server/test/test-utils.ts @@ -1,8 +1,8 @@ +import { AuthUserDto } from '@app/immich/decorators/auth-user.decorator'; +import { AuthGuard } from '@app/immich/middlewares/auth.guard'; import { CanActivate, ExecutionContext } from '@nestjs/common'; import { TestingModuleBuilder } from '@nestjs/testing'; import { DataSource } from 'typeorm'; -import { AuthUserDto } from '@app/immich/decorators/auth-user.decorator'; -import { AuthGuard } from '@app/immich/middlewares/auth.guard'; type CustomAuthCallback = () => AuthUserDto;