From 1e1e5cea686a8aba188446b629d8eba9eadc257c Mon Sep 17 00:00:00 2001 From: Jason Rasmussen Date: Fri, 14 Aug 2026 16:32:13 -0400 Subject: [PATCH] chore(server): remove unnused code --- e2e/src/fixtures.ts | 18 --------- e2e/src/responses.ts | 35 ------------------ .../ui/generators/timeline/timeline-config.ts | 7 ---- e2e/src/ui/specs/timeline/utils.ts | 14 +------ server/src/cores/storage.core.ts | 5 --- server/src/enum.ts | 8 ---- .../src/maintenance/maintenance-auth.guard.ts | 17 +-------- .../src/repositories/database.repository.ts | 29 --------------- .../machine-learning.repository.ts | 1 - server/src/repositories/person.repository.ts | 4 +- server/src/repositories/search.repository.ts | 2 - .../repositories/server-info.repository.ts | 10 ----- server/src/repositories/session.repository.ts | 2 - server/src/services/library.service.ts | 4 -- server/src/types.ts | 33 ----------------- server/src/utils/database.ts | 2 - server/src/utils/media.ts | 4 -- server/test/fixtures/auth.stub.ts | 13 ------- server/test/fixtures/file.stub.ts | 7 ---- server/test/fixtures/media.stub.ts | 22 ----------- server/test/medium/responses.ts | 27 -------------- server/test/small.factory.ts | 32 +--------------- server/test/utils.ts | 37 ------------------- 23 files changed, 5 insertions(+), 328 deletions(-) diff --git a/e2e/src/fixtures.ts b/e2e/src/fixtures.ts index 1e03ad6d24..a43e2c3e69 100644 --- a/e2e/src/fixtures.ts +++ b/e2e/src/fixtures.ts @@ -1,9 +1,7 @@ export const uuidDto = { - invalid: 'invalid-uuid', // valid uuid v4 notFound: '00000000-0000-4000-a000-000000000000', dummy: '00000000-0000-4000-a000-000000000001', - dummy2: '00000000-0000-4000-a000-000000000002', }; const adminLoginDto = { @@ -57,22 +55,6 @@ export const createUserDto = { }; export const userDto = { - admin: { - name: signupDto.admin.name, - email: signupDto.admin.email, - password: signupDto.admin.password, - storageLabel: 'admin', - oauthId: '', - shouldChangePassword: false, - profileImagePath: '', - createdAt: new Date('2021-01-01'), - deletedAt: null, - updatedAt: new Date('2021-01-01'), - tags: [], - assets: [], - quotaSizeInBytes: null, - quotaUsageInBytes: 0, - }, user1: { name: createUserDto.user1.name, email: createUserDto.user1.email, diff --git a/e2e/src/responses.ts b/e2e/src/responses.ts index 1b3447767e..337d101cb4 100644 --- a/e2e/src/responses.ts +++ b/e2e/src/responses.ts @@ -40,41 +40,6 @@ export const errorDto = { }, }; -export const signupResponseDto = { - admin: { - avatarColor: expect.any(String), - id: expect.any(String), - name: 'Immich Admin', - email: 'admin@immich.cloud', - storageLabel: 'admin', - profileImagePath: '', - // why? lol - shouldChangePassword: true, - isAdmin: true, - createdAt: expect.any(String), - updatedAt: expect.any(String), - deletedAt: null, - oauthId: '', - quotaUsageInBytes: 0, - quotaSizeInBytes: null, - status: 'active', - license: null, - profileChangedAt: expect.any(String), - }, -}; - -export const loginResponseDto = { - admin: { - accessToken: expect.any(String), - name: 'Immich Admin', - isAdmin: true, - isOnboarded: false, - profileImagePath: '', - shouldChangePassword: true, - userEmail: 'admin@immich.cloud', - userId: expect.any(String), - }, -}; export const deviceDto = { current: { id: expect.any(String), diff --git a/e2e/src/ui/generators/timeline/timeline-config.ts b/e2e/src/ui/generators/timeline/timeline-config.ts index a3b59bb8c8..5bfb2c1800 100644 --- a/e2e/src/ui/generators/timeline/timeline-config.ts +++ b/e2e/src/ui/generators/timeline/timeline-config.ts @@ -24,13 +24,6 @@ export const ASPECT_RATIO_WEIGHTS = { '3:1': 0.01, // 1% 3:1 panorama } as const; -export type AspectRatio = { - width: number; - height: number; - ratio: number; - name: string; -}; - // Mock configuration for asset generation - will be transformed to API response formats export type MockTimelineAsset = { id: string; diff --git a/e2e/src/ui/specs/timeline/utils.ts b/e2e/src/ui/specs/timeline/utils.ts index dad60266b9..986f794fb6 100644 --- a/e2e/src/ui/specs/timeline/utils.ts +++ b/e2e/src/ui/specs/timeline/utils.ts @@ -1,4 +1,4 @@ -import { BrowserContext, expect, Page } from '@playwright/test'; +import { expect, Page } from '@playwright/test'; import { DateTime } from 'luxon'; import { TimelineAssetConfig } from 'src/ui/generators/timeline'; @@ -11,18 +11,6 @@ export const padYearMonth = (yearMonth: string) => { return `${year}-${month.padStart(2, '0')}`; }; -export async function throttlePage(context: BrowserContext, page: Page) { - const session = await context.newCDPSession(page); - await session.send('Network.emulateNetworkConditions', { - offline: false, - downloadThroughput: (1.5 * 1024 * 1024) / 8, - uploadThroughput: (750 * 1024) / 8, - latency: 40, - connectionType: 'cellular3g', - }); - await session.send('Emulation.setCPUThrottlingRate', { rate: 10 }); -} - export const poll = async ( page: Page, query: () => Promise, diff --git a/server/src/cores/storage.core.ts b/server/src/cores/storage.core.ts index 185ab95e62..07b753f820 100644 --- a/server/src/cores/storage.core.ts +++ b/server/src/cores/storage.core.ts @@ -1,4 +1,3 @@ -import { randomUUID } from 'node:crypto'; import { dirname, join, resolve } from 'node:path'; import { StorageAsset } from 'src/database'; import { @@ -352,10 +351,6 @@ export class StorageCore { return join(StorageCore.getNestedFolder(folder, ownerId, filename), filename); } - static getTempPathInDir(dir: string): string { - return join(dir, `${randomUUID()}.tmp`); - } - private async getDevices() { try { return await this.storageRepository.readdir('/dev/dri'); diff --git a/server/src/enum.ts b/server/src/enum.ts index 8882b554f3..e88a9a667c 100644 --- a/server/src/enum.ts +++ b/server/src/enum.ts @@ -1211,14 +1211,6 @@ export enum ApiTag { Workflows = 'Workflows', } -export enum PluginContext { - Asset = 'asset', - Album = 'album', - Person = 'person', -} - -export const PluginContextSchema = z.enum(PluginContext).describe('Plugin context').meta({ id: 'PluginContextType' }); - export const WorkflowTriggerSchema = z .enum(WorkflowTrigger) .describe('Plugin trigger type') diff --git a/server/src/maintenance/maintenance-auth.guard.ts b/server/src/maintenance/maintenance-auth.guard.ts index 08aaad516b..e2c472ff71 100644 --- a/server/src/maintenance/maintenance-auth.guard.ts +++ b/server/src/maintenance/maintenance-auth.guard.ts @@ -1,11 +1,4 @@ -import { - CanActivate, - ExecutionContext, - Injectable, - SetMetadata, - applyDecorators, - createParamDecorator, -} from '@nestjs/common'; +import { CanActivate, ExecutionContext, Injectable, SetMetadata, applyDecorators } from '@nestjs/common'; import { Reflector } from '@nestjs/core'; import { Request } from 'express'; import { MaintenanceAuthDto } from 'src/dtos/maintenance.dto'; @@ -22,14 +15,6 @@ export interface MaintenanceAuthRequest extends Request { auth?: MaintenanceAuthDto; } -export interface MaintenanceAuthenticatedRequest extends Request { - auth: MaintenanceAuthDto; -} - -export const MaintenanceAuth = createParamDecorator((data, context: ExecutionContext): MaintenanceAuthDto => { - return context.switchToHttp().getRequest().auth; -}); - @Injectable() export class MaintenanceAuthGuard implements CanActivate { constructor( diff --git a/server/src/repositories/database.repository.ts b/server/src/repositories/database.repository.ts index 1b5592d356..165752783a 100644 --- a/server/src/repositories/database.repository.ts +++ b/server/src/repositories/database.repository.ts @@ -483,35 +483,6 @@ export class DatabaseRepository { await sql`SELECT pg_advisory_unlock(${lock})`.execute(connection); } - async revertLastMigration(): Promise { - this.logger.debug('Reverting last migration'); - - const migrator = this.createMigrator(); - const { error, results } = await migrator.migrateDown(); - - for (const result of results ?? []) { - if (result.status === 'Success') { - this.logger.log(`Reverted migration "${result.migrationName}"`); - } else if (result.status === 'Error') { - this.logger.warn(`Failed to revert migration "${result.migrationName}"`); - } - } - - if (error) { - this.logger.error(`Failed to revert migrations: ${error}`); - throw error; - } - - const reverted = results?.find((result) => result.direction === 'Down' && result.status === 'Success'); - if (!reverted) { - this.logger.debug('No migrations to revert'); - return undefined; - } - - this.logger.debug('Finished reverting migration'); - return reverted.migrationName; - } - private createMigrator(): Migrator { return new Migrator({ db: this.db, diff --git a/server/src/repositories/machine-learning.repository.ts b/server/src/repositories/machine-learning.repository.ts index c9825f31c1..a05ddbc866 100644 --- a/server/src/repositories/machine-learning.repository.ts +++ b/server/src/repositories/machine-learning.repository.ts @@ -73,7 +73,6 @@ export interface Face { } export type FacialRecognitionResponse = { [ModelTask.FACIAL_RECOGNITION]: Face[] } & VisualResponse; -export type DetectedFaces = { faces: Face[] } & VisualResponse; export type MachineLearningRequest = ClipVisualRequest | ClipTextualRequest | FacialRecognitionRequest | OcrRequest; export type TextEncodingOptions = ModelOptions & { language?: string }; diff --git a/server/src/repositories/person.repository.ts b/server/src/repositories/person.repository.ts index 0db03a18c7..8ea6ed50fb 100644 --- a/server/src/repositories/person.repository.ts +++ b/server/src/repositories/person.repository.ts @@ -1,5 +1,5 @@ import { Injectable } from '@nestjs/common'; -import { ExpressionBuilder, Insertable, Kysely, Selectable, sql, Updateable } from 'kysely'; +import { ExpressionBuilder, Insertable, Kysely, sql, Updateable } from 'kysely'; import { jsonObjectFrom } from 'kysely/helpers/postgres'; import { InjectKysely } from 'nestjs-kysely'; import { AssetFace } from 'src/database'; @@ -60,8 +60,6 @@ export interface GetAllFacesOptions { export type UnassignFacesOptions = DeleteFacesOptions; -export type SelectFaceOptions = (keyof Selectable)[]; - const withPerson = (eb: ExpressionBuilder) => { return jsonObjectFrom( eb.selectFrom('person').selectAll('person').whereRef('person.id', '=', 'asset_face.personId'), diff --git a/server/src/repositories/search.repository.ts b/server/src/repositories/search.repository.ts index 70ba09ef2c..4bde10f165 100644 --- a/server/src/repositories/search.repository.ts +++ b/server/src/repositories/search.repository.ts @@ -158,8 +158,6 @@ export type SmartSearchOptions = SearchDateOptions & SearchTagOptions & SearchOcrOptions & { visibility?: AssetVisibility | 'not-locked' }; -export type OcrSearchOptions = SearchDateOptions & SearchOcrOptions; - export type LargeAssetSearchOptions = AssetSearchOptions & { minFileSize?: number }; export interface FaceEmbeddingSearch extends SearchEmbeddingOptions { diff --git a/server/src/repositories/server-info.repository.ts b/server/src/repositories/server-info.repository.ts index 285ab4ee80..5cfded148d 100644 --- a/server/src/repositories/server-info.repository.ts +++ b/server/src/repositories/server-info.repository.ts @@ -8,16 +8,6 @@ import { ReleaseChannel } from 'src/dtos/system-config.dto'; import { ConfigRepository } from 'src/repositories/config.repository'; import { LoggingRepository } from 'src/repositories/logging.repository'; -export interface GitHubRelease { - id: number; - url: string; - tag_name: string; - name: string; - created_at: string; - published_at: string; - body: string; -} - export interface VersionResponse { version: string; published_at: string; diff --git a/server/src/repositories/session.repository.ts b/server/src/repositories/session.repository.ts index f1cb541b39..58a5e721c0 100644 --- a/server/src/repositories/session.repository.ts +++ b/server/src/repositories/session.repository.ts @@ -9,8 +9,6 @@ import { DB } from 'src/schema'; import { SessionTable } from 'src/schema/tables/session.table'; import { asUuid } from 'src/utils/database'; -export type SessionSearchOptions = { updatedBefore: Date }; - @Injectable() export class SessionRepository { constructor(@InjectKysely() private db: Kysely) {} diff --git a/server/src/services/library.service.ts b/server/src/services/library.service.ts index ac6112dcd7..fa405b9d22 100644 --- a/server/src/services/library.service.ts +++ b/server/src/services/library.service.ts @@ -444,10 +444,6 @@ export class LibraryService extends BaseService { await this.jobRepository.queue({ name: JobName.LibrarySyncAssetsQueueAll, data: { id } }); } - async queueScanAll() { - await this.jobRepository.queue({ name: JobName.LibraryScanQueueAll, data: {} }); - } - @OnJob({ name: JobName.LibraryScanQueueAll, queue: QueueName.Library }) async handleQueueScanAll(): Promise { this.logger.log(`Initiating scan of all external libraries...`); diff --git a/server/src/types.ts b/server/src/types.ts index 27995e841f..d31841ffd3 100644 --- a/server/src/types.ts +++ b/server/src/types.ts @@ -1,4 +1,3 @@ -import { WorkflowTrigger } from '@immich/plugin-sdk'; import { ShallowDehydrateObject } from 'kysely'; import { SystemConfig } from 'src/config'; import { VECTOR_EXTENSIONS } from 'src/constants'; @@ -30,7 +29,6 @@ import { SystemMetadataKey, TranscodeTarget, UserMetadataKey, - WorkflowType, } from 'src/enum'; import { Mocked } from 'vitest'; @@ -79,14 +77,6 @@ export interface DecodeToBufferOptions extends DecodeImageOptions { export type GenerateThumbnailOptions = Pick & DecodeToBufferOptions; export type GenerateThumbhashOptions = DecodeImageOptions; -export interface GenerateThumbnailsOptions { - colorspace: string; - preview?: ImageOptions; - processInvalidImages: boolean; - thumbhash?: boolean; - thumbnail?: ImageOptions; -} - export interface VideoStreamInfo { index: number; height: number; @@ -143,10 +133,6 @@ export interface ImageDimensions { height: number; } -export interface InputDimensions extends ImageDimensions { - inputPath: string; -} - export interface VideoInfo { format: VideoFormat; videoStreams: VideoStreamInfo[]; @@ -189,11 +175,6 @@ export interface BitrateDistribution { unit: string; } -export interface ImageBuffer { - data: Buffer; - info: RawImageInfo; -} - export interface VideoCodecSWConfig { getCommand( target: TranscodeTarget, @@ -260,18 +241,10 @@ export interface ILibraryBulkIdsJob { totalAssets: number; } -export interface IBulkEntityJob { - ids: string[]; -} - export interface IDeleteFilesJob extends IBaseJob { files: Array; } -export interface ISidecarWriteJob extends IEntityJob { - tags?: true; -} - export interface IDeferrableJob extends IEntityJob { deferred?: boolean; } @@ -307,12 +280,6 @@ export interface INotifyAlbumUpdateJob extends IEntityJob, IDelayedJob { recipientId: string; } -export type IWorkflowJob = { - id: string; - trigger: WorkflowTrigger; - type: T; -}; - export interface IIntegrityJob { refreshOnly?: boolean; } diff --git a/server/src/utils/database.ts b/server/src/utils/database.ts index 0f4d8775b6..5122b0a9d4 100644 --- a/server/src/utils/database.ts +++ b/server/src/utils/database.ts @@ -81,8 +81,6 @@ export const asUuid = (id: string | Expression) => sql`${id}::uu export const anyUuid = (ids: string[]) => sql`any(${`{${ids}}`}::uuid[])`; -export const asVector = (embedding: number[]) => sql`${`[${embedding}]`}::vector`; - export const unnest = (array: string[]) => sql>`unnest(array[${sql.join(array)}]::text[])`; export const removeUndefinedKeys = (update: T, template: unknown) => { diff --git a/server/src/utils/media.ts b/server/src/utils/media.ts index aea821d6d5..656e5bf441 100644 --- a/server/src/utils/media.ts +++ b/server/src/utils/media.ts @@ -712,10 +712,6 @@ export class NvencSwDecodeConfig extends BaseHWConfig { : ['-cq:v', String(this.config.crf)]; } - getThreadOptions() { - return []; - } - getEncoderOptions(): string[] { const out = this.getOutputThreadOptions(); if (this.tune.strictGop) { diff --git a/server/test/fixtures/auth.stub.ts b/server/test/fixtures/auth.stub.ts index 88a2278898..7ac7c14978 100644 --- a/server/test/fixtures/auth.stub.ts +++ b/server/test/fixtures/auth.stub.ts @@ -28,19 +28,6 @@ export const authStub = { id: 'token-id', } as AuthSession, }), - user2: Object.freeze({ - user: { - id: 'user-2', - name: 'User 2', - email: 'user2@immich.cloud', - isAdmin: false, - quotaSizeInBytes: null, - quotaUsageInBytes: 0, - }, - session: { - id: 'token-id', - } as AuthSession, - }), adminWithElevatedPermission: Object.freeze({ user: authUser.admin, session: { diff --git a/server/test/fixtures/file.stub.ts b/server/test/fixtures/file.stub.ts index f63d2d10fb..e64b769496 100644 --- a/server/test/fixtures/file.stub.ts +++ b/server/test/fixtures/file.stub.ts @@ -6,13 +6,6 @@ export const fileStub = { originalName: 'asset_1.jpeg', size: 42, }), - livePhotoMotion: Object.freeze({ - uuid: 'live-photo-motion-asset', - originalPath: 'fake_path/asset_1.mp4', - checksum: Buffer.from('live photo file hash', 'utf8'), - originalName: 'asset_1.mp4', - size: 69, - }), photo: Object.freeze({ uuid: 'photo', originalPath: 'fake_path/photo1.jpeg', diff --git a/server/test/fixtures/media.stub.ts b/server/test/fixtures/media.stub.ts index 77534fd6cb..4421a09801 100644 --- a/server/test/fixtures/media.stub.ts +++ b/server/test/fixtures/media.stub.ts @@ -451,28 +451,6 @@ export const videoInfoStub = { }, ], }), - videoStreamWithProfileLevel: Object.freeze({ - ...probeStubDefault, - videoStreams: [ - { - ...probeStubDefaultVideoStream[0], - codecName: 'h264', - profile: 100, - level: 40, - }, - ], - }), - audioStreamAAC: Object.freeze({ - ...probeStubDefault, - audioStreams: [ - { - index: 1, - codecName: 'aac', - profile: 2, - bitrate: 128_000, - }, - ], - }), }; interface SelectedStreams { diff --git a/server/test/medium/responses.ts b/server/test/medium/responses.ts index 9b75bc85ec..e8509e339b 100644 --- a/server/test/medium/responses.ts +++ b/server/test/medium/responses.ts @@ -1,27 +1,6 @@ import { expect } from 'vitest'; export const errorDto = { - unauthorized: { - message: 'Authentication required', - }, - forbidden: { - message: expect.any(String), - }, - missingPermission: (permission: string) => ({ - message: `Missing required permission: ${permission}`, - }), - wrongPassword: { - message: 'Wrong password', - }, - invalidToken: { - message: 'Invalid user token', - }, - invalidShareKey: { - message: 'Invalid share key', - }, - invalidSharePassword: { - message: 'Invalid password', - }, badRequest: (message: any = null) => ({ message: message ?? expect.anything(), }), @@ -29,10 +8,4 @@ export const errorDto = { message: 'Validation failed', errors: errors ? expect.arrayContaining(errors.map((e) => expect.objectContaining(e))) : expect.any(Array), }), - noPermission: { - message: expect.stringContaining('Not found or no'), - }, - incorrectLogin: { - message: 'Incorrect email or password', - }, }; diff --git a/server/test/small.factory.ts b/server/test/small.factory.ts index ae83727d70..545c05e881 100644 --- a/server/test/small.factory.ts +++ b/server/test/small.factory.ts @@ -1,7 +1,7 @@ -import { AuthApiKey, AuthSharedLink, AuthUser, Exif, Library, UserAdmin } from 'src/database'; +import { AuthApiKey, AuthSharedLink, AuthUser, Library, UserAdmin } from 'src/database'; import { AuthDto } from 'src/dtos/auth.dto'; import { QueueStatisticsDto } from 'src/dtos/queue.dto'; -import { AssetFileType, Permission, UserStatus } from 'src/enum'; +import { Permission, UserStatus } from 'src/enum'; import { v4, v7 } from 'uuid'; import { expect } from 'vitest'; @@ -168,31 +168,6 @@ const versionHistoryFactory = () => ({ version: '1.123.45', }); -const assetSidecarWriteFactory = () => { - const id = newUuid(); - return { - id, - originalPath: '/path/to/original-path.jpg.xmp', - tags: [], - files: [ - { - id: newUuid(), - path: '/path/to/original-path.jpg.xmp', - type: AssetFileType.Sidecar, - isEdited: false, - }, - ], - exifInfo: { - assetId: id, - description: 'this is a description', - latitude: 12, - longitude: 12, - dateTimeOriginal: '2023-11-22T04:56:12.196Z', - timeZone: 'UTC-6', - } as unknown as Exif, - }; -}; - const assetOcrFactory = ( ocr: { id?: string; @@ -236,9 +211,6 @@ export const factory = { library: libraryFactory, queueStatistics: queueStatisticsFactory, versionHistory: versionHistoryFactory, - jobAssets: { - sidecarWrite: assetSidecarWriteFactory, - }, uuid: newUuid, buffer: () => Buffer.from('this is a fake buffer'), date: newDate, diff --git a/server/test/utils.ts b/server/test/utils.ts index 2f32f3b412..e1920a4a79 100644 --- a/server/test/utils.ts +++ b/server/test/utils.ts @@ -553,43 +553,6 @@ export const mockDuplex = return duplex; }; -export const mockFork = vitest.fn((exitCode: number, stdout: string, stderr: string, error?: unknown) => { - const stdoutStream = new Readable({ - read() { - this.push(stdout); // write mock data to stdout - this.push(null); // end stream - }, - }); - - return { - stdout: stdoutStream, - stderr: new Readable({ - read() { - this.push(stderr); // write mock data to stderr - this.push(null); // end stream - }, - }), - stdin: new Writable({ - write(chunk, encoding, callback) { - callback(); - }, - }), - exitCode, - on: vitest.fn((event, callback: any) => { - if (event === 'close') { - stdoutStream.once('end', () => callback(0)); - } - if (event === 'error' && error) { - stdoutStream.once('end', () => callback(error)); - } - if (event === 'exit') { - stdoutStream.once('end', () => callback(exitCode)); - } - }), - kill: vitest.fn(), - } as unknown as ChildProcessWithoutNullStreams; -}); - export async function* makeStream(items: T[] = []): AsyncGenerator { for (const item of items) { await Promise.resolve();