mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
Merge branch '1086-api-make-sure-hookentityprepostdelete-is-used-across-the-board' into 1132-issue---api-make-sure-hookentityprepostcreate-is-used-across-the-board
This commit is contained in:
commit
aadd7fd08a
@ -793,8 +793,6 @@ export class BlockService extends BaseService<
|
|||||||
*
|
*
|
||||||
* @param _query - The Mongoose query object used for deletion.
|
* @param _query - The Mongoose query object used for deletion.
|
||||||
* @param criteria - The filter criteria for finding the labels to be deleted.
|
* @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')
|
@OnEvent('hook:label:preDelete')
|
||||||
async handleLabelPreDelete(
|
async handleLabelPreDelete(
|
||||||
|
@ -265,8 +265,6 @@ export class SubscriberService extends BaseService<
|
|||||||
*
|
*
|
||||||
* @param _query - The Mongoose query object used for deletion.
|
* @param _query - The Mongoose query object used for deletion.
|
||||||
* @param criteria - The filter criteria for finding the labels to be deleted.
|
* @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')
|
@OnEvent('hook:label:preDelete')
|
||||||
async handleLabelDelete(
|
async handleLabelDelete(
|
||||||
|
@ -123,8 +123,8 @@ describe('NlpEntityRepository', () => {
|
|||||||
it('should delete a nlp entity', async () => {
|
it('should delete a nlp entity', async () => {
|
||||||
nlpValueRepository.eventEmitter.once(
|
nlpValueRepository.eventEmitter.once(
|
||||||
'hook:nlpEntity:preDelete',
|
'hook:nlpEntity:preDelete',
|
||||||
async (...args) => {
|
async (...[query, criteria]) => {
|
||||||
await nlpService.handleEntityDelete(args[0], args[1]);
|
await nlpService.handleEntityDelete(query, criteria);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
const intentNlpEntity = await nlpEntityRepository.findOne({
|
const intentNlpEntity = await nlpEntityRepository.findOne({
|
||||||
|
@ -178,8 +178,8 @@ describe('NlpValueRepository', () => {
|
|||||||
it('should delete a nlp Value', async () => {
|
it('should delete a nlp Value', async () => {
|
||||||
nlpValueRepository.eventEmitter.once(
|
nlpValueRepository.eventEmitter.once(
|
||||||
'hook:nlpValue:preDelete',
|
'hook:nlpValue:preDelete',
|
||||||
async (...args) => {
|
async (...[query, criteria]) => {
|
||||||
await nlpService.handleValueDelete(args[0], args[1]);
|
await nlpService.handleValueDelete(query, criteria);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
const result = await nlpValueRepository.deleteOne(nlpValues[1].id);
|
const result = await nlpValueRepository.deleteOne(nlpValues[1].id);
|
||||||
|
@ -109,12 +109,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')
|
@OnEvent('hook:nlpEntity:preDelete')
|
||||||
async handleEntityDelete(_query: unknown, criteria: TFilterQuery<NlpEntity>) {
|
async handleEntityDelete(
|
||||||
|
_query: unknown,
|
||||||
|
criteria: TFilterQuery<NlpEntity>,
|
||||||
|
): Promise<void> {
|
||||||
if (criteria._id) {
|
if (criteria._id) {
|
||||||
await this.nlpValueService.deleteMany({ entity: criteria._id });
|
await this.nlpValueService.deleteMany({ entity: criteria._id });
|
||||||
await this.nlpSampleEntityService.deleteMany({ entity: criteria._id });
|
await this.nlpSampleEntityService.deleteMany({ entity: criteria._id });
|
||||||
@ -189,12 +193,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')
|
@OnEvent('hook:nlpValue:preDelete')
|
||||||
async handleValueDelete(_query: unknown, criteria: TFilterQuery<NlpValue>) {
|
async handleValueDelete(
|
||||||
|
_query: unknown,
|
||||||
|
criteria: TFilterQuery<NlpValue>,
|
||||||
|
): Promise<void> {
|
||||||
if (criteria._id) {
|
if (criteria._id) {
|
||||||
await this.nlpSampleEntityService.deleteMany({
|
await this.nlpSampleEntityService.deleteMany({
|
||||||
value: criteria._id,
|
value: criteria._id,
|
||||||
|
Loading…
Reference in New Issue
Block a user