fix(api): move builtin logic + adapt unit tests

This commit is contained in:
yassinedorbozgithub
2025-05-15 13:57:17 +01:00
parent 7a23b0ded7
commit 2f5c85cb64
5 changed files with 8 additions and 23 deletions

View File

@@ -223,20 +223,6 @@ export class NlpEntityController extends BaseController<
throw new BadRequestException('No IDs provided for deletion.');
}
const { count: builtinNlpEntitiesCount } = await this.filterCount({
_id: { $in: ids },
builtin: true,
});
if (builtinNlpEntitiesCount > 0) {
this.logger.warn(
`Unable to delete NLP entities with provided IDs: ${ids}`,
);
throw new MethodNotAllowedException(
'Deletion failed: Selection includes built-in NLP entities that are protected',
);
}
const deleteResult = await this.nlpEntityService.deleteMany({
_id: { $in: ids },
});

View File

@@ -163,7 +163,7 @@ describe('NlpValueController', () => {
entity: intentNlpEntity!.id,
value: 'updated',
expressions: [],
builtin: true,
builtin: false,
doc: '',
};
const result = await nlpValueController.updateOne(
@@ -191,7 +191,6 @@ describe('NlpValueController', () => {
describe('deleteMany', () => {
it('should delete multiple nlp values', async () => {
const valuesToDelete = [positiveValue!.id, negativeValue!.id];
const result = await nlpValueController.deleteMany(valuesToDelete);
expect(result.deletedCount).toEqual(valuesToDelete.length);

View File

@@ -232,7 +232,7 @@ describe('NlpEntityService', () => {
{
value: 'jhon',
expressions: ['john', 'joohn', 'jhonny'],
builtin: true,
builtin: false,
doc: '',
},
],