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 48187e7c71
commit ddbff0bc3c
11 changed files with 20 additions and 34 deletions

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';
@@ -102,7 +101,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.');
}
}