From 9d945370c1ff327d08fb8b0de3847d544744a882 Mon Sep 17 00:00:00 2001 From: yassinedorbozgithub Date: Thu, 12 Jun 2025 06:09:17 +0100 Subject: [PATCH 01/38] fix(api): resolve camelCased classname --- api/src/utils/generics/base-repository.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/src/utils/generics/base-repository.ts b/api/src/utils/generics/base-repository.ts index 18ef046f..79a3d448 100644 --- a/api/src/utils/generics/base-repository.ts +++ b/api/src/utils/generics/base-repository.ts @@ -37,6 +37,7 @@ import { } from '@/utils/types/filter.types'; import { flatten } from '../helpers/flatten'; +import { camelCase } from '../helpers/misc'; import { PageQueryDto, QuerySortDto } from '../pagination/pagination-query.dto'; import { DtoAction, DtoConfig, DtoInfer } from '../types/dto.types'; @@ -128,7 +129,7 @@ export abstract class BaseRepository< * @returns A type-safe event name string. */ getEventName(suffix: EHook) { - const entity = this.cls.name.toLocaleLowerCase(); + const entity = camelCase(this.cls.name); return `hook:${entity}:${suffix}` as `hook:${IHookEntities}:${TNormalizedEvents}`; } From c7bc4143bc4837d1d18cbc07484af7e39685b165 Mon Sep 17 00:00:00 2001 From: yassinedorbozgithub Date: Thu, 12 Jun 2025 11:26:28 +0100 Subject: [PATCH 02/38] fix: add utilty function --- api/src/utils/helpers/criteria.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 api/src/utils/helpers/criteria.ts diff --git a/api/src/utils/helpers/criteria.ts b/api/src/utils/helpers/criteria.ts new file mode 100644 index 00000000..140cfb8c --- /dev/null +++ b/api/src/utils/helpers/criteria.ts @@ -0,0 +1,19 @@ +/* + * Copyright © 2025 Hexastack. All rights reserved. + * + * Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms: + * 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission. + * 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 { FilterQuery } from 'mongoose'; + +export const getCriteriaIds = ( + criteria: FilterQuery, +) => { + return Array.isArray(criteria._id.$in) + ? criteria._id.$in + : Array.isArray(criteria._id) + ? criteria._id + : [criteria._id]; +}; From 8cff20c8611f6c063a17270667811d71cbb207b6 Mon Sep 17 00:00:00 2001 From: yassinedorbozgithub Date: Thu, 12 Jun 2025 11:26:52 +0100 Subject: [PATCH 03/38] fix: update repositories --- api/src/chat/repositories/label.repository.ts | 33 +------------ .../nlp/repositories/nlp-entity.repository.ts | 48 +------------------ .../nlp/repositories/nlp-value.repository.ts | 44 +---------------- 3 files changed, 6 insertions(+), 119 deletions(-) diff --git a/api/src/chat/repositories/label.repository.ts b/api/src/chat/repositories/label.repository.ts index bf5bcdd7..cfab4b44 100644 --- a/api/src/chat/repositories/label.repository.ts +++ b/api/src/chat/repositories/label.repository.ts @@ -8,10 +8,9 @@ import { Injectable } from '@nestjs/common'; import { InjectModel } from '@nestjs/mongoose'; -import { Document, Model, Query } from 'mongoose'; +import { Model } from 'mongoose'; -import { BaseRepository, DeleteResult } from '@/utils/generics/base-repository'; -import { TFilterQuery } from '@/utils/types/filter.types'; +import { BaseRepository } from '@/utils/generics/base-repository'; import { LabelDto } from '../dto/label.dto'; import { @@ -59,32 +58,4 @@ export class LabelRepository extends BaseRepository< }, ); } - - /** - * Before deleting a label, this method fetches the label(s) based on the given criteria and emits a delete event. - * - * @param query - The Mongoose query object used for deletion. - * @param criteria - The filter criteria for finding the labels to be deleted. - * - * @returns {Promise} A promise that resolves once the event is emitted. - */ - async preDelete( - _query: Query< - DeleteResult, - Document, - unknown, - Label, - 'deleteOne' | 'deleteMany' - >, - _criteria: TFilterQuery