diff --git a/api/src/nlp/controllers/nlp-value.controller.ts b/api/src/nlp/controllers/nlp-value.controller.ts index 3bae3093..b85caab3 100644 --- a/api/src/nlp/controllers/nlp-value.controller.ts +++ b/api/src/nlp/controllers/nlp-value.controller.ts @@ -168,10 +168,7 @@ export class NlpValueController extends BaseController< @Param('id') id: string, @Body() updateNlpValueDto: NlpValueUpdateDto, ): Promise { - const result = await this.nlpValueService.updateOne(id, { - ...updateNlpValueDto, - entity: updateNlpValueDto.entity || undefined, - }); + const result = await this.nlpValueService.updateOne(id, updateNlpValueDto); if (!result) { this.logger.warn(`Unable to update NLP Value by id ${id}`); throw new NotFoundException(`NLP Value with ID ${id} not found`); diff --git a/api/src/nlp/dto/nlp-value.dto.ts b/api/src/nlp/dto/nlp-value.dto.ts index a60ffa60..837141dd 100644 --- a/api/src/nlp/dto/nlp-value.dto.ts +++ b/api/src/nlp/dto/nlp-value.dto.ts @@ -6,7 +6,6 @@ * 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file). */ -import { PartialType } from '@nestjs/mapped-types'; import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; import { IsArray, @@ -52,8 +51,38 @@ export class NlpValueCreateDto { entity: string | null; } -export class NlpValueUpdateDto extends PartialType(NlpValueCreateDto) {} +export class NlpValueUpdateDto { + @ApiPropertyOptional({ description: 'Foreign ID', type: String }) + @IsOptional() + @IsString() + foreign_id?: string; + + @ApiPropertyOptional({ description: 'Nlp value', type: String }) + @IsOptional() + @IsString() + value?: string; + + @ApiPropertyOptional({ + description: 'Nlp value expressions', + isArray: true, + type: Array, + }) + @IsOptional() + @IsArray() + expressions?: string[]; + + @ApiPropertyOptional({ description: 'Nlp value entity', type: String }) + @IsString() + @IsObjectId({ message: 'Entity must be a valid ObjectId' }) + entity?: string | null; + + @ApiPropertyOptional({ description: 'Nlp value is builtin', type: Boolean }) + @IsOptional() + @IsBoolean() + builtin?: boolean; +} export type NlpValueDto = DtoConfig<{ create: NlpValueCreateDto; + update: NlpValueUpdateDto; }>; diff --git a/api/src/utils/generics/base-repository.ts b/api/src/utils/generics/base-repository.ts index e5137757..e0c4fd65 100644 --- a/api/src/utils/generics/base-repository.ts +++ b/api/src/utils/generics/base-repository.ts @@ -478,7 +478,7 @@ export abstract class BaseRepository< async updateOne>( criteria: string | TFilterQuery, - dto: UpdateQuery, + dto: UpdateQuery>, options: QueryOptions | null = { new: true, }, diff --git a/api/src/utils/generics/base-service.ts b/api/src/utils/generics/base-service.ts index e0df7774..bbedbcea 100644 --- a/api/src/utils/generics/base-service.ts +++ b/api/src/utils/generics/base-service.ts @@ -177,7 +177,7 @@ export abstract class BaseService< async updateOne( criteria: string | TFilterQuery, - dto: Partial, + dto: DtoInfer>, options?: QueryOptions> | null, ): Promise { return await this.repository.updateOne(criteria, dto, options);