fix(api): remove type-only imports of injectable classes to fix NestJS DI

Type-only imports (`import { type X }`) strip runtime type metadata
needed by NestJS dependency injection via reflect-metadata. This caused
`UnknownDependenciesException` errors where constructor parameters
resolved to `Function` instead of the actual class.

Fixed 129 files across all modules:
- Services (LoggerService, PrismaService, CacheService, etc.)
- CQRS buses (EventBus, QueryBus, CommandBus)
- DTOs used with @Body()/@Query() decorators in controllers
- Payment gateway services and search repositories

Also fixed E2E test infrastructure:
- auth.fixture.ts: use destructuring pattern for Playwright fixture
- global-teardown.ts: correct column names (Lead.agentId, Transaction.buyerId)
- inquiries.spec.ts: flexible response property checks
- payments-callback.spec.ts: accept 500 for unknown provider

All 111 API E2E tests now pass.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Ho Ngoc Hai
2026-04-12 20:43:35 +07:00
parent 4f406dab02
commit c658e540f0
129 changed files with 256 additions and 252 deletions

View File

@@ -1,8 +1,8 @@
import { InternalServerErrorException } from '@nestjs/common';
import { CommandHandler, type CommandBus, type ICommandHandler, type QueryBus } from '@nestjs/cqrs';
import { CommandHandler, CommandBus, type ICommandHandler, QueryBus } from '@nestjs/cqrs';
import { createId } from '@paralleldrive/cuid2';
import { type SavedSearch, type Prisma } from '@prisma/client';
import { DomainException, ValidationException, type PrismaService, type LoggerService } from '@modules/shared';
import { DomainException, ValidationException, PrismaService, LoggerService } from '@modules/shared';
import { CheckQuotaQuery, type QuotaCheckResult, MeterUsageCommand } from '@modules/subscriptions';
import { CreateSavedSearchCommand } from './create-saved-search.command';

View File

@@ -1,6 +1,6 @@
import { InternalServerErrorException } from '@nestjs/common';
import { CommandHandler, type ICommandHandler } from '@nestjs/cqrs';
import { DomainException, ForbiddenException, NotFoundException, type PrismaService, type LoggerService } from '@modules/shared';
import { DomainException, ForbiddenException, NotFoundException, PrismaService, LoggerService } from '@modules/shared';
import { DeleteSavedSearchCommand } from './delete-saved-search.command';
@CommandHandler(DeleteSavedSearchCommand)

View File

@@ -1,7 +1,7 @@
import { InternalServerErrorException } from '@nestjs/common';
import { CommandHandler, type ICommandHandler } from '@nestjs/cqrs';
import { type Prisma } from '@prisma/client';
import { DomainException, ForbiddenException, NotFoundException, ValidationException, type PrismaService, type LoggerService } from '@modules/shared';
import { DomainException, ForbiddenException, NotFoundException, ValidationException, PrismaService, LoggerService } from '@modules/shared';
import { UpdateSavedSearchCommand } from './update-saved-search.command';
export interface UpdateSavedSearchResult {

View File

@@ -1,6 +1,6 @@
import { Inject, InternalServerErrorException } from '@nestjs/common';
import { type IQueryHandler, QueryHandler } from '@nestjs/cqrs';
import { CacheService, CachePrefix, CacheTTL, DomainException, type LoggerService } from '@modules/shared';
import { CacheService, CachePrefix, CacheTTL, DomainException, LoggerService } from '@modules/shared';
import {
SEARCH_REPOSITORY,
type ISearchRepository,

View File

@@ -1,6 +1,6 @@
import { InternalServerErrorException } from '@nestjs/common';
import { QueryHandler, type IQueryHandler } from '@nestjs/cqrs';
import { DomainException, ForbiddenException, NotFoundException, type LoggerService, type PrismaService } from '@modules/shared';
import { DomainException, ForbiddenException, NotFoundException, LoggerService, PrismaService } from '@modules/shared';
import { GetSavedSearchQuery } from './get-saved-search.query';
export interface SavedSearchDetail {

View File

@@ -1,6 +1,6 @@
import { InternalServerErrorException } from '@nestjs/common';
import { QueryHandler, type IQueryHandler } from '@nestjs/cqrs';
import { DomainException, type LoggerService, type PrismaService } from '@modules/shared';
import { DomainException, LoggerService, PrismaService } from '@modules/shared';
import { GetSavedSearchesQuery } from './get-saved-searches.query';
export interface SavedSearchItem {

View File

@@ -1,6 +1,6 @@
import { Inject, InternalServerErrorException } from '@nestjs/common';
import { type IQueryHandler, QueryHandler } from '@nestjs/cqrs';
import { CacheService, CachePrefix, CacheTTL, DomainException, type LoggerService } from '@modules/shared';
import { CacheService, CachePrefix, CacheTTL, DomainException, LoggerService } from '@modules/shared';
import {
SEARCH_REPOSITORY,
type ISearchRepository,

View File

@@ -1,8 +1,8 @@
import { Injectable } from '@nestjs/common';
import { type CommandBus } from '@nestjs/cqrs';
import { CommandBus } from '@nestjs/cqrs';
import { Cron, CronExpression } from '@nestjs/schedule';
import { SendNotificationCommand } from '@modules/notifications';
import { type PrismaService, type LoggerService } from '@modules/shared';
import { PrismaService, LoggerService } from '@modules/shared';
/**
* Daily cron job that checks saved searches against new listings published since lastAlertAt.

View File

@@ -1,8 +1,8 @@
import { Injectable } from '@nestjs/common';
import { type CommandBus } from '@nestjs/cqrs';
import { CommandBus } from '@nestjs/cqrs';
import { OnEvent } from '@nestjs/event-emitter';
import { SendNotificationCommand } from '@modules/notifications';
import { type PrismaService, type LoggerService } from '@modules/shared';
import { PrismaService, LoggerService } from '@modules/shared';
/**
* When a new listing is approved, check all saved searches with alerts enabled

View File

@@ -1,6 +1,6 @@
import { Inject, Injectable } from '@nestjs/common';
import { Prisma } from '@prisma/client';
import { type LoggerService, type PrismaService } from '@modules/shared';
import { LoggerService, PrismaService } from '@modules/shared';
import {
SEARCH_REPOSITORY,
type ISearchRepository,

View File

@@ -1,6 +1,6 @@
import { Injectable } from '@nestjs/common';
import { Prisma } from '@prisma/client';
import { type LoggerService, type PrismaService } from '@modules/shared';
import { LoggerService, PrismaService } from '@modules/shared';
import {
type ISearchRepository,
type ListingDocument,

View File

@@ -5,7 +5,7 @@ import {
CircuitBreaker,
CircuitOpenError,
type CircuitState,
type LoggerService,
LoggerService,
} from '@modules/shared';
import {
type ISearchRepository,
@@ -13,8 +13,8 @@ import {
type SearchParams,
type SearchResult,
} from '../../domain/repositories/search.repository';
import { type PostgresSearchRepository } from './postgres-search.repository';
import { type TypesenseSearchRepository } from './typesense-search.repository';
import { PostgresSearchRepository } from './postgres-search.repository';
import { TypesenseSearchRepository } from './typesense-search.repository';
export const SEARCH_DEGRADATION_TOTAL = 'search_degradation_total';

View File

@@ -9,7 +9,7 @@ import {
Query,
UseGuards,
} from '@nestjs/common';
import { type CommandBus, type QueryBus } from '@nestjs/cqrs';
import { CommandBus, QueryBus } from '@nestjs/cqrs';
import {
ApiTags,
ApiOperation,
@@ -27,7 +27,7 @@ import { type SavedSearchDetail } from '../../application/queries/get-saved-sear
import { GetSavedSearchQuery } from '../../application/queries/get-saved-search/get-saved-search.query';
import { type SavedSearchListResult } from '../../application/queries/get-saved-searches/get-saved-searches.handler';
import { GetSavedSearchesQuery } from '../../application/queries/get-saved-searches/get-saved-searches.query';
import { type CreateSavedSearchDto, type UpdateSavedSearchDto, type SavedSearchListDto } from '../dto/saved-search.dto';
import { CreateSavedSearchDto, UpdateSavedSearchDto, SavedSearchListDto } from '../dto/saved-search.dto';
@ApiTags('saved-searches')
@ApiBearerAuth('JWT')

View File

@@ -5,7 +5,7 @@ import {
Query,
UseGuards,
} from '@nestjs/common';
import { type CommandBus, type QueryBus } from '@nestjs/cqrs';
import { CommandBus, QueryBus } from '@nestjs/cqrs';
import {
ApiTags,
ApiOperation,
@@ -19,8 +19,8 @@ import { type ReindexResult } from '../../application/commands/reindex-all/reind
import { GeoSearchQuery } from '../../application/queries/geo-search/geo-search.query';
import { SearchPropertiesQuery } from '../../application/queries/search-properties/search-properties.query';
import { type SearchResult } from '../../domain/repositories/search.repository';
import { type GeoSearchDto } from '../dto/geo-search.dto';
import { type SearchPropertiesDto } from '../dto/search-properties.dto';
import { GeoSearchDto } from '../dto/geo-search.dto';
import { SearchPropertiesDto } from '../dto/search-properties.dto';
@ApiTags('search')
@Controller('search')