mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
fix(api): nlp document _id
This commit is contained in:
parent
4b4028161a
commit
ac618ccb6d
@ -20,9 +20,17 @@
|
|||||||
import { v4 as uuidv4 } from 'uuid';
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
|
|
||||||
import { LoggerService } from '@/logger/logger.service';
|
import { LoggerService } from '@/logger/logger.service';
|
||||||
import { NlpEntity, NlpEntityFull } from '@/nlp/schemas/nlp-entity.schema';
|
import {
|
||||||
|
NlpEntity,
|
||||||
|
NlpEntityDocument,
|
||||||
|
NlpEntityFull,
|
||||||
|
} from '@/nlp/schemas/nlp-entity.schema';
|
||||||
import { NlpSample, NlpSampleFull } from '@/nlp/schemas/nlp-sample.schema';
|
import { NlpSample, NlpSampleFull } from '@/nlp/schemas/nlp-sample.schema';
|
||||||
import { NlpValue, NlpValueFull } from '@/nlp/schemas/nlp-value.schema';
|
import {
|
||||||
|
NlpValue,
|
||||||
|
NlpValueDocument,
|
||||||
|
NlpValueFull,
|
||||||
|
} from '@/nlp/schemas/nlp-value.schema';
|
||||||
import { Settings } from '@/setting/schemas/types';
|
import { Settings } from '@/setting/schemas/types';
|
||||||
|
|
||||||
import { Nlp } from './types';
|
import { Nlp } from './types';
|
||||||
@ -68,7 +76,7 @@ export default abstract class BaseNlpHelper {
|
|||||||
* @param entity - The entity to add
|
* @param entity - The entity to add
|
||||||
* @returns The added entity otherwise an error
|
* @returns The added entity otherwise an error
|
||||||
*/
|
*/
|
||||||
addEntity(_entity: NlpEntity): Promise<string> {
|
addEntity(_entity: NlpEntityDocument): Promise<string> {
|
||||||
return new Promise((resolve, _reject) => {
|
return new Promise((resolve, _reject) => {
|
||||||
return resolve(uuidv4());
|
return resolve(uuidv4());
|
||||||
});
|
});
|
||||||
@ -103,7 +111,7 @@ export default abstract class BaseNlpHelper {
|
|||||||
*
|
*
|
||||||
* @returns The added value otherwise it should throw an error
|
* @returns The added value otherwise it should throw an error
|
||||||
*/
|
*/
|
||||||
addValue(_value: NlpValue): Promise<string> {
|
addValue(_value: NlpValueDocument): Promise<string> {
|
||||||
return new Promise((resolve, _reject) => {
|
return new Promise((resolve, _reject) => {
|
||||||
return resolve(uuidv4());
|
return resolve(uuidv4());
|
||||||
});
|
});
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { EventEmitter2 } from '@nestjs/event-emitter';
|
import { EventEmitter2 } from '@nestjs/event-emitter';
|
||||||
import { InjectModel } from '@nestjs/mongoose';
|
import { InjectModel } from '@nestjs/mongoose';
|
||||||
import { Document, Model, Query, TFilterQuery, Types } from 'mongoose';
|
import { Document, Model, Query, TFilterQuery } from 'mongoose';
|
||||||
|
|
||||||
import { BaseRepository, DeleteResult } from '@/utils/generics/base-repository';
|
import { BaseRepository, DeleteResult } from '@/utils/generics/base-repository';
|
||||||
|
|
||||||
@ -18,6 +18,7 @@ import { NlpValueRepository } from './nlp-value.repository';
|
|||||||
import {
|
import {
|
||||||
NLP_ENTITY_POPULATE,
|
NLP_ENTITY_POPULATE,
|
||||||
NlpEntity,
|
NlpEntity,
|
||||||
|
NlpEntityDocument,
|
||||||
NlpEntityFull,
|
NlpEntityFull,
|
||||||
NlpEntityPopulate,
|
NlpEntityPopulate,
|
||||||
} from '../schemas/nlp-entity.schema';
|
} from '../schemas/nlp-entity.schema';
|
||||||
@ -44,11 +45,8 @@ export class NlpEntityRepository extends BaseRepository<
|
|||||||
*
|
*
|
||||||
* @param created - The newly created NLP entity document.
|
* @param created - The newly created NLP entity document.
|
||||||
*/
|
*/
|
||||||
async postCreate(
|
async postCreate(_created: NlpEntityDocument): Promise<void> {
|
||||||
_created: Document<unknown, object, NlpEntity> &
|
if (!_created) {
|
||||||
NlpEntity & { _id: Types.ObjectId },
|
|
||||||
): Promise<void> {
|
|
||||||
if (!_created.builtin) {
|
|
||||||
// Bypass builtin entities (probably fixtures)
|
// Bypass builtin entities (probably fixtures)
|
||||||
this.eventEmitter.emit('hook:nlpEntity:create', _created);
|
this.eventEmitter.emit('hook:nlpEntity:create', _created);
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ import { NlpSampleEntityRepository } from './nlp-sample-entity.repository';
|
|||||||
import {
|
import {
|
||||||
NLP_VALUE_POPULATE,
|
NLP_VALUE_POPULATE,
|
||||||
NlpValue,
|
NlpValue,
|
||||||
|
NlpValueDocument,
|
||||||
NlpValueFull,
|
NlpValueFull,
|
||||||
NlpValuePopulate,
|
NlpValuePopulate,
|
||||||
} from '../schemas/nlp-value.schema';
|
} from '../schemas/nlp-value.schema';
|
||||||
@ -40,7 +41,7 @@ export class NlpValueRepository extends BaseRepository<
|
|||||||
*
|
*
|
||||||
* @param created - The newly created NLP value document.
|
* @param created - The newly created NLP value document.
|
||||||
*/
|
*/
|
||||||
async postCreate(created: NlpValue): Promise<void> {
|
async postCreate(created: NlpValueDocument): Promise<void> {
|
||||||
if (!created.builtin) {
|
if (!created.builtin) {
|
||||||
// Bypass builtin entities (probably fixtures)
|
// Bypass builtin entities (probably fixtures)
|
||||||
this.eventEmitter.emit('hook:nlpValue:create', created);
|
this.eventEmitter.emit('hook:nlpValue:create', created);
|
||||||
|
Loading…
Reference in New Issue
Block a user