chore(server): remove unused dependencies class-transformer and class-validator from package.json

This commit is contained in:
timonrieger 2026-03-06 23:37:36 +01:00
parent d45a78f52f
commit 896e7ea1aa
No known key found for this signature in database
11 changed files with 20 additions and 34 deletions

13
pnpm-lock.yaml generated
View File

@ -436,12 +436,6 @@ importers:
chokidar:
specifier: ^4.0.3
version: 4.0.3
class-transformer:
specifier: ^0.5.1
version: 0.5.1
class-validator:
specifier: ^0.14.0
version: 0.14.4
compression:
specifier: ^1.8.0
version: 1.8.1
@ -18257,13 +18251,15 @@ snapshots:
cjs-module-lexer@2.2.0: {}
class-transformer@0.5.1: {}
class-transformer@0.5.1:
optional: true
class-validator@0.14.4:
dependencies:
'@types/validator': 13.15.10
libphonenumber-js: 1.12.38
validator: 13.15.26
optional: true
clean-css@5.3.3:
dependencies:
@ -21104,7 +21100,8 @@ snapshots:
prelude-ls: 1.2.1
type-check: 0.4.0
libphonenumber-js@1.12.38: {}
libphonenumber-js@1.12.38:
optional: true
lightningcss-android-arm64@1.31.1:
optional: true

View File

@ -65,8 +65,6 @@
"body-parser": "^2.2.0",
"bullmq": "^5.51.0",
"chokidar": "^4.0.3",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.0",
"compression": "^1.8.0",
"cookie": "^1.0.2",
"cookie-parser": "^1.4.7",

View File

@ -3,7 +3,6 @@ import { INestApplication } from '@nestjs/common';
import { Reflector } from '@nestjs/core';
import { SchedulerRegistry } from '@nestjs/schedule';
import { Test } from '@nestjs/testing';
import { ClassConstructor } from 'class-transformer';
import { ClsModule } from 'nestjs-cls';
import { KyselyModule } from 'nestjs-kysely';
import { OpenTelemetryModule } from 'nestjs-otel';
@ -44,7 +43,7 @@ export class SqlLogger {
const reflector = new Reflector();
type Repository = ClassConstructor<any>;
type Repository = new (...args: any[]) => any;
type SqlGeneratorOptions = { targetDir: string };
class SqlGenerator {

View File

@ -1,6 +1,5 @@
import { Injectable } from '@nestjs/common';
import { ModuleRef, Reflector } from '@nestjs/core';
import { ClassConstructor } from 'class-transformer';
import _ from 'lodash';
import { Socket } from 'socket.io';
import { SystemConfig } from 'src/config';
@ -152,7 +151,7 @@ export class EventRepository {
this.logger.setContext(EventRepository.name);
}
setup({ services }: { services: ClassConstructor<unknown>[] }) {
setup({ services }: { services: (new (...args: any[]) => unknown)[] }) {
const reflector = this.moduleRef.get(Reflector, { strict: false });
const items: Item<EmitEvent>[] = [];
const worker = this.configRepository.getWorker();

View File

@ -2,7 +2,6 @@ import { getQueueToken } from '@nestjs/bullmq';
import { Injectable } from '@nestjs/common';
import { ModuleRef, Reflector } from '@nestjs/core';
import { JobsOptions, Queue, Worker } from 'bullmq';
import { ClassConstructor } from 'class-transformer';
import { setTimeout } from 'node:timers/promises';
import { JobConfig } from 'src/decorators';
import { QueueJobResponseDto, QueueJobSearchDto } from 'src/dtos/queue.dto';
@ -34,7 +33,7 @@ export class JobRepository {
this.logger.setContext(JobRepository.name);
}
setup(services: ClassConstructor<unknown>[]) {
setup(services: (new (...args: any[]) => unknown)[]) {
const reflector = this.moduleRef.get(Reflector, { strict: false });
// discovery

View File

@ -11,7 +11,6 @@ import { resourceFromAttributes } from '@opentelemetry/resources';
import { AggregationType } from '@opentelemetry/sdk-metrics';
import { NodeSDK, contextBase } from '@opentelemetry/sdk-node';
import { ATTR_SERVICE_NAME, ATTR_SERVICE_VERSION } from '@opentelemetry/semantic-conventions';
import { ClassConstructor } from 'class-transformer';
import { snakeCase, startCase } from 'lodash';
import { MetricService } from 'nestjs-otel';
import { copyMetadataFromFunctionToFunction } from 'nestjs-otel/lib/opentelemetry.utils';
@ -118,7 +117,7 @@ export class TelemetryRepository {
this.repo = new MetricGroupRepository(metricService).configure({ enabled: metrics.has(ImmichTelemetry.Repo) });
}
setup({ repositories }: { repositories: ClassConstructor<unknown>[] }) {
setup({ repositories }: { repositories: (new (...args: any[]) => unknown)[] }) {
const { telemetry } = this.configRepository.getEnv();
const { metrics } = telemetry;
if (!metrics.has(ImmichTelemetry.Repo)) {
@ -136,7 +135,7 @@ export class TelemetryRepository {
}
}
private wrap(Repository: ClassConstructor<unknown>) {
private wrap(Repository: new (...args: any[]) => unknown) {
const className = Repository.name;
const descriptors = Object.getOwnPropertyDescriptors(Repository.prototype);
const unit = 'ms';

View File

@ -1,5 +1,4 @@
import { BadRequestException, ForbiddenException, Injectable, UnauthorizedException } from '@nestjs/common';
import { isString } from 'class-validator';
import { parse } from 'cookie';
import { DateTime } from 'luxon';
import { IncomingHttpHeaders } from 'node:http';
@ -307,7 +306,7 @@ export class AuthService extends BaseService {
const storageLabel = this.getClaim(profile, {
key: storageLabelClaim,
default: '',
isValid: isString,
isValid: (value: unknown): value is string => typeof value === 'string',
});
const storageQuota = this.getClaim(profile, {
key: storageQuotaClaim,
@ -317,7 +316,7 @@ export class AuthService extends BaseService {
const role = this.getClaim<'admin' | 'user'>(profile, {
key: roleClaim,
default: 'user',
isValid: (value: unknown) => isString(value) && ['admin', 'user'].includes(value),
isValid: (value: unknown) => typeof value === 'string' && ['admin', 'user'].includes(value),
});
const userName = profile.name ?? `${profile.given_name || ''} ${profile.family_name || ''}`;

View File

@ -1,4 +1,3 @@
import { plainToInstance } from 'class-transformer';
import { defaults, SystemConfig } from 'src/config';
import { SystemConfigDto } from 'src/dtos/system-config.dto';
import { AssetFileType, JobName, JobStatus, UserMetadataKey } from 'src/enum';
@ -101,7 +100,7 @@ describe(NotificationService.name, () => {
it('skips smtp validation with DTO when there are no changes', async () => {
const oldConfig = { ...configs.smtpEnabled };
const newConfig = plainToInstance(SystemConfigDto, configs.smtpEnabled);
const newConfig = configs.smtpEnabled as SystemConfigDto;
await expect(sut.onConfigValidate({ oldConfig, newConfig })).resolves.not.toThrow();
expect(mocks.email.verifySmtp).not.toHaveBeenCalled();

View File

@ -1,5 +1,4 @@
import { BadRequestException, Injectable } from '@nestjs/common';
import { ClassConstructor } from 'class-transformer';
import { SystemConfig } from 'src/config';
import { OnEvent } from 'src/decorators';
import { AuthDto } from 'src/dtos/auth.dto';
@ -39,7 +38,7 @@ const asNightlyTasksCron = (config: SystemConfig) => {
@Injectable()
export class QueueService extends BaseService {
private services: ClassConstructor<unknown>[] = [];
private services: (new (...args: any[]) => unknown)[] = [];
private nightlyJobsLock = false;
@OnEvent({ name: 'ConfigInit' })
@ -96,7 +95,7 @@ export class QueueService extends BaseService {
}
}
setServices(services: ClassConstructor<unknown>[]) {
setServices(services: (new (...args: any[]) => unknown)[]) {
this.services = services;
}

View File

@ -1,5 +1,4 @@
import { BadRequestException, Injectable } from '@nestjs/common';
import { instanceToPlain } from 'class-transformer';
import _ from 'lodash';
import { defaults } from 'src/config';
import { OnEvent } from 'src/decorators';
@ -61,7 +60,7 @@ export class SystemConfigService extends BaseService {
@OnEvent({ name: 'ConfigValidate' })
onConfigValidate({ newConfig, oldConfig }: ArgOf<'ConfigValidate'>) {
const { logLevel } = this.configRepository.getEnv();
if (!_.isEqual(instanceToPlain(newConfig.logging), oldConfig.logging) && logLevel) {
if (!_.isEqual(toPlainObject(newConfig.logging), oldConfig.logging) && logLevel) {
throw new Error('Logging cannot be changed while the environment variable IMMICH_LOG_LEVEL is set.');
}
}

View File

@ -3,7 +3,6 @@ import { CallHandler, ExecutionContext, Provider } from '@nestjs/common';
import { APP_FILTER, APP_GUARD, APP_INTERCEPTOR, APP_PIPE } from '@nestjs/core';
import { transformException } from '@nestjs/platform-express/multer/multer/multer.utils';
import { Test } from '@nestjs/testing';
import { ClassConstructor } from 'class-transformer';
import { NextFunction } from 'express';
import { Kysely } from 'kysely';
import multer from 'multer';
@ -93,7 +92,7 @@ export type ControllerContext = {
close: () => Promise<void>;
};
export const controllerSetup = async (controller: ClassConstructor<unknown>, providers: Provider[]) => {
export const controllerSetup = async (controller: new (...args: any[]) => unknown, providers: Provider[]) => {
const noopInterceptor = { intercept: (ctx: never, next: CallHandler<unknown>) => next.handle() };
const upload = multer({ storage: multer.memoryStorage() });
const memoryFileInterceptor = {
@ -164,14 +163,14 @@ const mockFn = (label: string, { strict }: { strict: boolean }) => {
});
};
export const mockBaseService = <T extends BaseService>(service: ClassConstructor<T>) => {
export const mockBaseService = <T extends BaseService>(service: new (...args: any[]) => T) => {
return automock(service, { args: [{ setContext: () => {} }], strict: false });
};
export const automock = <T>(
Dependency: ClassConstructor<T>,
Dependency: new (...args: any[]) => T,
options?: {
args?: ConstructorParameters<ClassConstructor<T>>;
args?: ConstructorParameters<new (...args: any[]) => T>;
strict?: boolean;
},
): AutoMocked<T> => {