fix: update the DTOs types naming

This commit is contained in:
yassinedorbozgithub 2025-01-10 08:32:40 +01:00
parent 13e94e5079
commit 5c4d9af9cf
8 changed files with 24 additions and 16 deletions

View File

@ -58,6 +58,6 @@ export class ConversationCreateDto {
next?: string[];
}
export type ConversationCrudsDto = DtoConfig<{
export type ConversationDTOCruds = DtoConfig<{
create: ConversationCreateDto;
}>;

View File

@ -13,7 +13,7 @@ import { Model } from 'mongoose';
import { BaseRepository } from '@/utils/generics/base-repository';
import { ConversationCrudsDto } from '../dto/conversation.dto';
import { ConversationDTOCruds } from '../dto/conversation.dto';
import {
Conversation,
CONVERSATION_POPULATE,
@ -26,7 +26,7 @@ export class ConversationRepository extends BaseRepository<
Conversation,
ConversationPopulate,
ConversationFull,
ConversationCrudsDto
ConversationDTOCruds
> {
constructor(
readonly eventEmitter: EventEmitter2,

View File

@ -12,7 +12,7 @@ import EventWrapper from '@/channel/lib/EventWrapper';
import { LoggerService } from '@/logger/logger.service';
import { BaseService } from '@/utils/generics/base-service';
import { ConversationCrudsDto } from '../dto/conversation.dto';
import { ConversationDTOCruds } from '../dto/conversation.dto';
import { VIEW_MORE_PAYLOAD } from '../helpers/constants';
import { ConversationRepository } from '../repositories/conversation.repository';
import { Block, BlockFull } from '../schemas/block.schema';
@ -32,7 +32,7 @@ export class ConversationService extends BaseService<
Conversation,
ConversationPopulate,
ConversationFull,
ConversationCrudsDto
ConversationDTOCruds
> {
constructor(
readonly repository: ConversationRepository,

View File

@ -100,6 +100,6 @@ export class UserResetPasswordDto extends PickType(UserCreateDto, [
export class UserRequestResetDto extends PickType(UserCreateDto, ['email']) {}
export type UserCrudsDto = DtoConfig<{
export type UserDTOCruds = DtoConfig<{
create: UserCreateDto;
}>;

View File

@ -20,7 +20,7 @@ import {
import { BaseRepository } from '@/utils/generics/base-repository';
import { TFilterQuery } from '@/utils/types/filter.types';
import { UserCrudsDto, UserEditProfileDto } from '../dto/user.dto';
import { UserDTOCruds, UserEditProfileDto } from '../dto/user.dto';
import {
User,
USER_POPULATE,
@ -35,7 +35,7 @@ export class UserRepository extends BaseRepository<
User,
UserPopulate,
UserFull,
UserCrudsDto
UserDTOCruds
> {
constructor(
readonly eventEmitter: EventEmitter2,

View File

@ -10,7 +10,7 @@ import { Injectable } from '@nestjs/common';
import { BaseService } from '@/utils/generics/base-service';
import { UserCrudsDto } from '../dto/user.dto';
import { UserDTOCruds } from '../dto/user.dto';
import { UserRepository } from '../repositories/user.repository';
import { User, UserFull, UserPopulate } from '../schemas/user.schema';
@ -19,7 +19,7 @@ export class UserService extends BaseService<
User,
UserPopulate,
UserFull,
UserCrudsDto
UserDTOCruds
> {
constructor(readonly repository: UserRepository) {
super(repository);

View File

@ -71,7 +71,7 @@ export abstract class BaseRepository<
T extends FlattenMaps<unknown>,
P extends string = never,
TFull extends Omit<T, P> = never,
DTO extends DtoProps<T> = unknown,
DTOCruds extends DtoProps<T> = unknown,
U = Omit<T, keyof BaseSchema>,
D = Document<T>,
> {
@ -456,7 +456,7 @@ export abstract class BaseRepository<
return await this.model.countDocuments(criteria).exec();
}
async create(dto: DtoInfer<DtoOperations.Create, DTO, U>): Promise<T> {
async create(dto: DtoInfer<DtoOperations.Create, DTOCruds, U>): Promise<T> {
const doc = await this.model.create(dto);
return plainToClass(

View File

@ -23,10 +23,10 @@ export abstract class BaseService<
T extends BaseSchema,
P extends string = never,
TFull extends Omit<T, P> = never,
DTO extends DtoProps<any> = unknown,
DTOCruds extends DtoProps<any> = unknown,
> {
constructor(
protected readonly repository: BaseRepository<T, P, TFull, DTO>,
protected readonly repository: BaseRepository<T, P, TFull, DTOCruds>,
) {}
getRepository() {
@ -145,7 +145,11 @@ export abstract class BaseService<
}
async create<
D extends DtoInfer<DtoOperations.Create, DTO, Omit<T, keyof BaseSchema>>,
D extends DtoInfer<
DtoOperations.Create,
DTOCruds,
Omit<T, keyof BaseSchema>
>,
>(dto: D): Promise<T> {
try {
return await this.repository.create(dto);
@ -160,7 +164,11 @@ export abstract class BaseService<
}
async findOneOrCreate<
D extends DtoInfer<DtoOperations.Create, DTO, Omit<T, keyof BaseSchema>>,
D extends DtoInfer<
DtoOperations.Create,
DTOCruds,
Omit<T, keyof BaseSchema>
>,
>(criteria: string | TFilterQuery<T>, dto: D): Promise<T> {
const result = await this.findOne(criteria);
if (!result) {