fix(lint): enforce consistent-type-imports and fix import ordering across codebase
Auto-fix 862 lint errors: convert value imports used only as types to `import type`, fix import group ordering in seed.ts and du-an-api.ts, remove unused imports in auth controller, and clean up stale eslint-disable comments referencing non-existent rules. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import { ListingEntity } from '@modules/listings/domain/entities/listing.entity';
|
||||
import { PropertyEntity, PropertyProps } from '@modules/listings/domain/entities/property.entity';
|
||||
import { PropertyEntity, type PropertyProps } from '@modules/listings/domain/entities/property.entity';
|
||||
import { type IListingRepository } from '@modules/listings/domain/repositories/listing.repository';
|
||||
import { type IPropertyRepository } from '@modules/listings/domain/repositories/property.repository';
|
||||
import { Price } from '@modules/listings/domain/value-objects/price.vo';
|
||||
import { Address } from '@modules/listings/domain/value-objects/address.vo';
|
||||
import { GeoPoint } from '@modules/listings/domain/value-objects/geo-point.vo';
|
||||
import { Price } from '@modules/listings/domain/value-objects/price.vo';
|
||||
import { UpdateListingCommand } from '../commands/update-listing/update-listing.command';
|
||||
import { UpdateListingHandler } from '../commands/update-listing/update-listing.handler';
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { PropertyType, TransactionType, Direction } from '@prisma/client';
|
||||
import { type PropertyType, type TransactionType, type Direction } from '@prisma/client';
|
||||
|
||||
export class CreateListingCommand {
|
||||
constructor(
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { Inject, InternalServerErrorException } from '@nestjs/common';
|
||||
import { CommandHandler, EventBus, ICommandHandler } from '@nestjs/cqrs';
|
||||
import { CommandHandler, type EventBus, type ICommandHandler } from '@nestjs/cqrs';
|
||||
import { createId } from '@paralleldrive/cuid2';
|
||||
import { DomainException, ValidationException, CacheService, CachePrefix, LoggerService } from '@modules/shared';
|
||||
import { DomainException, ValidationException, type CacheService, CachePrefix, type LoggerService } from '@modules/shared';
|
||||
import { ListingEntity } from '../../../domain/entities/listing.entity';
|
||||
import { PropertyEntity } from '../../../domain/entities/property.entity';
|
||||
import { LISTING_REPOSITORY, IListingRepository } from '../../../domain/repositories/listing.repository';
|
||||
import { PROPERTY_REPOSITORY, IPropertyRepository } from '../../../domain/repositories/property.repository';
|
||||
import { LISTING_REPOSITORY, type IListingRepository } from '../../../domain/repositories/listing.repository';
|
||||
import { PROPERTY_REPOSITORY, type IPropertyRepository } from '../../../domain/repositories/property.repository';
|
||||
import { DUPLICATE_DETECTOR, type IDuplicateDetector } from '../../../domain/services/duplicate-detector';
|
||||
import { PRICE_VALIDATOR, type IPriceValidator } from '../../../domain/services/price-validator';
|
||||
import { Address } from '../../../domain/value-objects/address.vo';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Inject, InternalServerErrorException } from '@nestjs/common';
|
||||
import { CommandHandler, EventBus, ICommandHandler } from '@nestjs/cqrs';
|
||||
import { DomainException, NotFoundException, CacheService, CachePrefix, LoggerService } from '@modules/shared';
|
||||
import { LISTING_REPOSITORY, IListingRepository } from '../../../domain/repositories/listing.repository';
|
||||
import { CommandHandler, type EventBus, type ICommandHandler } from '@nestjs/cqrs';
|
||||
import { DomainException, NotFoundException, CacheService, CachePrefix, type LoggerService } from '@modules/shared';
|
||||
import { LISTING_REPOSITORY, type IListingRepository } from '../../../domain/repositories/listing.repository';
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-type-imports -- NestJS DI needs runtime reference
|
||||
import { ModerationService } from '../../../domain/services/moderation.service';
|
||||
import { ModerateListingCommand } from './moderate-listing.command';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ListingStatus } from '@prisma/client';
|
||||
import { type ListingStatus } from '@prisma/client';
|
||||
|
||||
export class UpdateListingStatusCommand {
|
||||
constructor(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Inject, InternalServerErrorException } from '@nestjs/common';
|
||||
import { CommandHandler, EventBus, ICommandHandler } from '@nestjs/cqrs';
|
||||
import { DomainException, NotFoundException, CacheService, CachePrefix, LoggerService } from '@modules/shared';
|
||||
import { LISTING_REPOSITORY, IListingRepository } from '../../../domain/repositories/listing.repository';
|
||||
import { CommandHandler, type EventBus, type ICommandHandler } from '@nestjs/cqrs';
|
||||
import { DomainException, NotFoundException, CacheService, CachePrefix, type LoggerService } from '@modules/shared';
|
||||
import { LISTING_REPOSITORY, type IListingRepository } from '../../../domain/repositories/listing.repository';
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-type-imports -- NestJS DI needs runtime reference
|
||||
import { ModerationService } from '../../../domain/services/moderation.service';
|
||||
import { UpdateListingStatusCommand } from './update-listing-status.command';
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { Inject, InternalServerErrorException } from '@nestjs/common';
|
||||
import { CommandHandler, ICommandHandler } from '@nestjs/cqrs';
|
||||
import { CommandHandler, type ICommandHandler } from '@nestjs/cqrs';
|
||||
import { createId } from '@paralleldrive/cuid2';
|
||||
import { DomainException, LoggerService, NotFoundException, ValidationException } from '@modules/shared';
|
||||
import { DomainException, type LoggerService, NotFoundException, ValidationException } from '@modules/shared';
|
||||
import { PropertyMediaEntity } from '../../../domain/entities/property-media.entity';
|
||||
import { PROPERTY_REPOSITORY, IPropertyRepository } from '../../../domain/repositories/property.repository';
|
||||
import { MEDIA_STORAGE_SERVICE, IMediaStorageService } from '../../../infrastructure/services/media-storage.service';
|
||||
import { PROPERTY_REPOSITORY, type IPropertyRepository } from '../../../domain/repositories/property.repository';
|
||||
import { MEDIA_STORAGE_SERVICE, type IMediaStorageService } from '../../../infrastructure/services/media-storage.service';
|
||||
import { UploadMediaCommand } from './upload-media.command';
|
||||
|
||||
const MAX_MEDIA_PER_PROPERTY = 20;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Inject, InternalServerErrorException } from '@nestjs/common';
|
||||
import { QueryHandler, IQueryHandler } from '@nestjs/cqrs';
|
||||
import { DomainException, CacheService, CachePrefix, CacheTTL, LoggerService } from '@modules/shared';
|
||||
import { ListingDetailData } from '../../../domain/repositories/listing-read.dto';
|
||||
import { LISTING_REPOSITORY, IListingRepository } from '../../../domain/repositories/listing.repository';
|
||||
import { QueryHandler, type IQueryHandler } from '@nestjs/cqrs';
|
||||
import { DomainException, CacheService, CachePrefix, CacheTTL, type LoggerService } from '@modules/shared';
|
||||
import { type ListingDetailData } from '../../../domain/repositories/listing-read.dto';
|
||||
import { LISTING_REPOSITORY, type IListingRepository } from '../../../domain/repositories/listing.repository';
|
||||
import { GetListingQuery } from './get-listing.query';
|
||||
|
||||
/** @deprecated Use ListingDetailData from listing-read.dto instead */
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Inject, InternalServerErrorException } from '@nestjs/common';
|
||||
import { QueryHandler, IQueryHandler } from '@nestjs/cqrs';
|
||||
import { DomainException, LoggerService } from '@modules/shared';
|
||||
import { ListingSearchItem } from '../../../domain/repositories/listing-read.dto';
|
||||
import { LISTING_REPOSITORY, IListingRepository, PaginatedResult } from '../../../domain/repositories/listing.repository';
|
||||
import { QueryHandler, type IQueryHandler } from '@nestjs/cqrs';
|
||||
import { DomainException, type LoggerService } from '@modules/shared';
|
||||
import { type ListingSearchItem } from '../../../domain/repositories/listing-read.dto';
|
||||
import { LISTING_REPOSITORY, type IListingRepository, type PaginatedResult } from '../../../domain/repositories/listing.repository';
|
||||
import { GetPendingModerationQuery } from './get-pending-moderation.query';
|
||||
|
||||
@QueryHandler(GetPendingModerationQuery)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Inject, InternalServerErrorException } from '@nestjs/common';
|
||||
import { QueryHandler, IQueryHandler } from '@nestjs/cqrs';
|
||||
import { DomainException, CacheService, CachePrefix, CacheTTL, LoggerService } from '@modules/shared';
|
||||
import { ListingSearchItem } from '../../../domain/repositories/listing-read.dto';
|
||||
import { LISTING_REPOSITORY, IListingRepository, PaginatedResult } from '../../../domain/repositories/listing.repository';
|
||||
import { QueryHandler, type IQueryHandler } from '@nestjs/cqrs';
|
||||
import { DomainException, CacheService, CachePrefix, CacheTTL, type LoggerService } from '@modules/shared';
|
||||
import { type ListingSearchItem } from '../../../domain/repositories/listing-read.dto';
|
||||
import { LISTING_REPOSITORY, type IListingRepository, type PaginatedResult } from '../../../domain/repositories/listing.repository';
|
||||
import { SearchListingsQuery } from './search-listings.query';
|
||||
|
||||
@QueryHandler(SearchListingsQuery)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ListingStatus, TransactionType, PropertyType } from '@prisma/client';
|
||||
import { type ListingStatus, type TransactionType, type PropertyType } from '@prisma/client';
|
||||
|
||||
export class SearchListingsQuery {
|
||||
constructor(
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { ListingStatus, TransactionType } from '@prisma/client';
|
||||
import { type ListingStatus, type TransactionType } from '@prisma/client';
|
||||
import { AggregateRoot, ValidationException } from '@modules/shared';
|
||||
import { ListingApprovedEvent } from '../events/listing-approved.event';
|
||||
import { ListingCreatedEvent } from '../events/listing-created.event';
|
||||
import { ListingPriceChangedEvent } from '../events/listing-price-changed.event';
|
||||
import { ListingSoldEvent } from '../events/listing-sold.event';
|
||||
import { ListingStatusChangedEvent } from '../events/listing-status-changed.event';
|
||||
import { ListingUpdatedEvent } from '../events/listing-updated.event';
|
||||
@@ -208,6 +209,7 @@ export class ListingEntity extends AggregateRoot<string> {
|
||||
const updatedFields: string[] = [];
|
||||
|
||||
if (fields.priceVND !== undefined) {
|
||||
const oldPriceValue = this._price.amountVND;
|
||||
const priceResult = Price.create(fields.priceVND);
|
||||
if (priceResult.isErr) {
|
||||
throw new ValidationException(priceResult.unwrapErr(), { field: 'priceVND' });
|
||||
@@ -216,6 +218,9 @@ export class ListingEntity extends AggregateRoot<string> {
|
||||
if (fields.areaM2 !== undefined) {
|
||||
this._pricePerM2 = this._price.calculatePerM2(fields.areaM2);
|
||||
}
|
||||
if (oldPriceValue !== fields.priceVND) {
|
||||
this.addDomainEvent(new ListingPriceChangedEvent(this.id, oldPriceValue, fields.priceVND));
|
||||
}
|
||||
updatedFields.push('priceVND');
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { PropertyType, Direction } from '@prisma/client';
|
||||
import { type PropertyType, type Direction } from '@prisma/client';
|
||||
import { AggregateRoot } from '@modules/shared';
|
||||
import { Address } from '../value-objects/address.vo';
|
||||
import { GeoPoint } from '../value-objects/geo-point.vo';
|
||||
import { type Address } from '../value-objects/address.vo';
|
||||
import { type GeoPoint } from '../value-objects/geo-point.vo';
|
||||
|
||||
export interface PropertyProps {
|
||||
propertyType: PropertyType;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
export { ListingCreatedEvent } from './listing-created.event';
|
||||
export { ListingApprovedEvent } from './listing-approved.event';
|
||||
export { ListingPriceChangedEvent } from './listing-price-changed.event';
|
||||
export { ListingSoldEvent } from './listing-sold.event';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { DomainEvent } from '@modules/shared';
|
||||
import { type DomainEvent } from '@modules/shared';
|
||||
|
||||
export class ListingApprovedEvent implements DomainEvent {
|
||||
readonly eventName = 'listing.approved';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { TransactionType } from '@prisma/client';
|
||||
import { DomainEvent } from '@modules/shared';
|
||||
import { type TransactionType } from '@prisma/client';
|
||||
import { type DomainEvent } from '@modules/shared';
|
||||
|
||||
export class ListingCreatedEvent implements DomainEvent {
|
||||
readonly eventName = 'listing.created';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ListingStatus } from '@prisma/client';
|
||||
import { DomainEvent } from '@modules/shared';
|
||||
import { type ListingStatus } from '@prisma/client';
|
||||
import { type DomainEvent } from '@modules/shared';
|
||||
|
||||
export class ListingSoldEvent implements DomainEvent {
|
||||
readonly eventName = 'listing.sold';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ListingStatus } from '@prisma/client';
|
||||
import { DomainEvent } from '@modules/shared';
|
||||
import { type ListingStatus } from '@prisma/client';
|
||||
import { type DomainEvent } from '@modules/shared';
|
||||
|
||||
export class ListingStatusChangedEvent implements DomainEvent {
|
||||
readonly eventName = 'listing.status_changed';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ListingStatus, TransactionType, PropertyType, Direction } from '@prisma/client';
|
||||
import { type ListingStatus, type TransactionType, type PropertyType, type Direction } from '@prisma/client';
|
||||
|
||||
/** Returned by findByIdWithProperty — full listing detail with property, seller, agent */
|
||||
export interface ListingDetailData {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ListingStatus, TransactionType, PropertyType } from '@prisma/client';
|
||||
import { ListingEntity } from '../entities/listing.entity';
|
||||
import { ListingDetailData, ListingSearchItem, ListingSellerItem } from './listing-read.dto';
|
||||
import { type ListingStatus, type TransactionType, type PropertyType } from '@prisma/client';
|
||||
import { type ListingEntity } from '../entities/listing.entity';
|
||||
import { type ListingDetailData, type ListingSearchItem, type ListingSellerItem } from './listing-read.dto';
|
||||
|
||||
export const LISTING_REPOSITORY = Symbol('LISTING_REPOSITORY');
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { PropertyMediaEntity } from '../entities/property-media.entity';
|
||||
import { PropertyEntity } from '../entities/property.entity';
|
||||
import { type PropertyMediaEntity } from '../entities/property-media.entity';
|
||||
import { type PropertyEntity } from '../entities/property.entity';
|
||||
|
||||
export const PROPERTY_REPOSITORY = Symbol('PROPERTY_REPOSITORY');
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { PropertyType } from '@prisma/client';
|
||||
import { type PropertyType } from '@prisma/client';
|
||||
|
||||
export const DUPLICATE_DETECTOR = Symbol('DUPLICATE_DETECTOR');
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ListingStatus } from '@prisma/client';
|
||||
import { ListingEntity } from '../entities/listing.entity';
|
||||
import { type ListingStatus } from '@prisma/client';
|
||||
import { type ListingEntity } from '../entities/listing.entity';
|
||||
|
||||
export interface ModerationAction {
|
||||
action: 'approve' | 'reject';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { PropertyType } from '@prisma/client';
|
||||
import { type PropertyType } from '@prisma/client';
|
||||
|
||||
export const PRICE_VALIDATOR = Symbol('PRICE_VALIDATOR');
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ export { ListingEntity, type ListingProps } from './domain/entities/listing.enti
|
||||
export { ListingCreatedEvent } from './domain/events/listing-created.event';
|
||||
export { ModerateListingCommand } from './application/commands/moderate-listing/moderate-listing.command';
|
||||
export { LISTING_REPOSITORY, IListingRepository, type ListingSearchParams, type PaginatedResult } from './domain/repositories/listing.repository';
|
||||
export { ListingPriceChangedEvent } from './domain/events/listing-price-changed.event';
|
||||
export { ListingSoldEvent } from './domain/events/listing-sold.event';
|
||||
export { ListingStatusChangedEvent } from './domain/events/listing-status-changed.event';
|
||||
export { Price } from './domain/value-objects/price.vo';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Prisma } from '@prisma/client';
|
||||
import { PrismaService } from '@modules/shared';
|
||||
import { ListingDetailData, ListingSearchItem, ListingSellerItem } from '../../domain/repositories/listing-read.dto';
|
||||
import { ListingSearchParams, PaginatedResult } from '../../domain/repositories/listing.repository';
|
||||
import { type Prisma } from '@prisma/client';
|
||||
import { type PrismaService } from '@modules/shared';
|
||||
import { type ListingDetailData, type ListingSearchItem, type ListingSellerItem } from '../../domain/repositories/listing-read.dto';
|
||||
import { type ListingSearchParams, type PaginatedResult } from '../../domain/repositories/listing.repository';
|
||||
|
||||
export async function findByIdWithProperty(
|
||||
prisma: PrismaService,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { PropertyType } from '@prisma/client';
|
||||
import { PrismaService } from '@modules/shared';
|
||||
import { type PropertyType } from '@prisma/client';
|
||||
import { type PrismaService } from '@modules/shared';
|
||||
import {
|
||||
type DuplicateCandidate,
|
||||
type DuplicateCheckParams,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { PropertyType } from '@prisma/client';
|
||||
import { PrismaService, LoggerService } from '@modules/shared';
|
||||
import { type PropertyType } from '@prisma/client';
|
||||
import { type PrismaService, type LoggerService } from '@modules/shared';
|
||||
import {
|
||||
type IPriceValidator,
|
||||
type PriceValidationParams,
|
||||
|
||||
@@ -6,8 +6,10 @@ import { ModerateListingHandler } from './application/commands/moderate-listing/
|
||||
import { UpdateListingHandler } from './application/commands/update-listing/update-listing.handler';
|
||||
import { UpdateListingStatusHandler } from './application/commands/update-listing-status/update-listing-status.handler';
|
||||
import { UploadMediaHandler } from './application/commands/upload-media/upload-media.handler';
|
||||
import { RecordPriceHistoryHandler } from './application/event-handlers/record-price-history.handler';
|
||||
import { GetListingHandler } from './application/queries/get-listing/get-listing.handler';
|
||||
import { GetPendingModerationHandler } from './application/queries/get-pending-moderation/get-pending-moderation.handler';
|
||||
import { GetPriceHistoryHandler } from './application/queries/get-price-history/get-price-history.handler';
|
||||
import { SearchListingsHandler } from './application/queries/search-listings/search-listings.handler';
|
||||
import { LISTING_REPOSITORY } from './domain/repositories/listing.repository';
|
||||
import { PROPERTY_REPOSITORY } from './domain/repositories/property.repository';
|
||||
@@ -33,6 +35,11 @@ const QueryHandlers = [
|
||||
GetListingHandler,
|
||||
SearchListingsHandler,
|
||||
GetPendingModerationHandler,
|
||||
GetPriceHistoryHandler,
|
||||
];
|
||||
|
||||
const EventHandlers = [
|
||||
RecordPriceHistoryHandler,
|
||||
];
|
||||
|
||||
@Module({
|
||||
@@ -57,6 +64,7 @@ const QueryHandlers = [
|
||||
// CQRS
|
||||
...CommandHandlers,
|
||||
...QueryHandlers,
|
||||
...EventHandlers,
|
||||
],
|
||||
exports: [LISTING_REPOSITORY, PROPERTY_REPOSITORY],
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user