mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
Merge branch '1132-issue---api-make-sure-hookentityprepostcreate-is-used-across-the-board' into 1134-issue---api-make-sure-hookentityprepostupdate-is-used-across-the-board
This commit is contained in:
commit
6001fef761
@ -793,8 +793,6 @@ export class BlockService extends BaseService<
|
||||
*
|
||||
* @param _query - The Mongoose query object used for deletion.
|
||||
* @param criteria - The filter criteria for finding the labels to be deleted.
|
||||
*
|
||||
* @returns {Promise<void>} A promise that resolves once the event is emitted.
|
||||
*/
|
||||
@OnEvent('hook:label:preDelete')
|
||||
async handleLabelPreDelete(
|
||||
|
@ -265,8 +265,6 @@ export class SubscriberService extends BaseService<
|
||||
*
|
||||
* @param _query - The Mongoose query object used for deletion.
|
||||
* @param criteria - The filter criteria for finding the labels to be deleted.
|
||||
*
|
||||
* @returns {Promise<void>} A promise that resolves once the event is emitted.
|
||||
*/
|
||||
@OnEvent('hook:label:preDelete')
|
||||
async handleLabelDelete(
|
||||
|
@ -123,8 +123,8 @@ describe('NlpEntityRepository', () => {
|
||||
it('should delete a nlp entity', async () => {
|
||||
nlpValueRepository.eventEmitter.once(
|
||||
'hook:nlpEntity:preDelete',
|
||||
async (...args) => {
|
||||
await nlpService.handleEntityDelete(args[0], args[1]);
|
||||
async (...[query, criteria]) => {
|
||||
await nlpService.handleEntityDelete(query, criteria);
|
||||
},
|
||||
);
|
||||
const intentNlpEntity = await nlpEntityRepository.findOne({
|
||||
|
@ -178,8 +178,8 @@ describe('NlpValueRepository', () => {
|
||||
it('should delete a nlp Value', async () => {
|
||||
nlpValueRepository.eventEmitter.once(
|
||||
'hook:nlpValue:preDelete',
|
||||
async (...args) => {
|
||||
await nlpService.handleValueDelete(args[0], args[1]);
|
||||
async (...[query, criteria]) => {
|
||||
await nlpService.handleValueDelete(query, criteria);
|
||||
},
|
||||
);
|
||||
const result = await nlpValueRepository.deleteOne(nlpValues[1].id);
|
||||
|
@ -123,12 +123,16 @@ export class NlpService {
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the event triggered when an NLP entity is deleted. Synchronizes the deletion with the external NLP provider.
|
||||
* Before deleting a `nlpEntity`, this method deletes the related `nlpValue` and `nlpSampleEntity`. Synchronizes the deletion with the external NLP provider
|
||||
*
|
||||
* @param entity - The NLP entity to be deleted.
|
||||
* @param _query - The Mongoose query object used for deletion.
|
||||
* @param criteria - The filter criteria for finding the nlpEntities to be deleted.
|
||||
*/
|
||||
@OnEvent('hook:nlpEntity:preDelete')
|
||||
async handleEntityDelete(_query: unknown, criteria: TFilterQuery<NlpEntity>) {
|
||||
async handleEntityDelete(
|
||||
_query: unknown,
|
||||
criteria: TFilterQuery<NlpEntity>,
|
||||
): Promise<void> {
|
||||
if (criteria._id) {
|
||||
await this.nlpValueService.deleteMany({ entity: criteria._id });
|
||||
await this.nlpSampleEntityService.deleteMany({ entity: criteria._id });
|
||||
@ -216,12 +220,16 @@ export class NlpService {
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the event triggered when an NLP value is deleted. Synchronizes the deletion with the external NLP provider.
|
||||
* Before deleting a `nlpValue`, this method deletes the related `nlpSampleEntity`. Synchronizes the deletion with the external NLP provider
|
||||
*
|
||||
* @param value - The NLP value to be deleted.
|
||||
* @param _query - The Mongoose query object used for deletion.
|
||||
* @param criteria - The filter criteria for finding the nlpValues to be deleted.
|
||||
*/
|
||||
@OnEvent('hook:nlpValue:preDelete')
|
||||
async handleValueDelete(_query: unknown, criteria: TFilterQuery<NlpValue>) {
|
||||
async handleValueDelete(
|
||||
_query: unknown,
|
||||
criteria: TFilterQuery<NlpValue>,
|
||||
): Promise<void> {
|
||||
if (criteria._id) {
|
||||
await this.nlpSampleEntityService.deleteMany({
|
||||
value: criteria._id,
|
||||
|
Loading…
Reference in New Issue
Block a user