mirror of
https://github.com/hexastack/hexabot
synced 2025-02-22 20:38:32 +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 { 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 { 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 { Nlp } from './types';
|
||||
@ -68,7 +76,7 @@ export default abstract class BaseNlpHelper {
|
||||
* @param entity - The entity to add
|
||||
* @returns The added entity otherwise an error
|
||||
*/
|
||||
addEntity(_entity: NlpEntity): Promise<string> {
|
||||
addEntity(_entity: NlpEntityDocument): Promise<string> {
|
||||
return new Promise((resolve, _reject) => {
|
||||
return resolve(uuidv4());
|
||||
});
|
||||
@ -103,7 +111,7 @@ export default abstract class BaseNlpHelper {
|
||||
*
|
||||
* @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 resolve(uuidv4());
|
||||
});
|
||||
|
@ -9,7 +9,7 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { EventEmitter2 } from '@nestjs/event-emitter';
|
||||
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';
|
||||
|
||||
@ -18,6 +18,7 @@ import { NlpValueRepository } from './nlp-value.repository';
|
||||
import {
|
||||
NLP_ENTITY_POPULATE,
|
||||
NlpEntity,
|
||||
NlpEntityDocument,
|
||||
NlpEntityFull,
|
||||
NlpEntityPopulate,
|
||||
} from '../schemas/nlp-entity.schema';
|
||||
@ -44,11 +45,8 @@ export class NlpEntityRepository extends BaseRepository<
|
||||
*
|
||||
* @param created - The newly created NLP entity document.
|
||||
*/
|
||||
async postCreate(
|
||||
_created: Document<unknown, object, NlpEntity> &
|
||||
NlpEntity & { _id: Types.ObjectId },
|
||||
): Promise<void> {
|
||||
if (!_created.builtin) {
|
||||
async postCreate(_created: NlpEntityDocument): Promise<void> {
|
||||
if (!_created) {
|
||||
// Bypass builtin entities (probably fixtures)
|
||||
this.eventEmitter.emit('hook:nlpEntity:create', _created);
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ import { NlpSampleEntityRepository } from './nlp-sample-entity.repository';
|
||||
import {
|
||||
NLP_VALUE_POPULATE,
|
||||
NlpValue,
|
||||
NlpValueDocument,
|
||||
NlpValueFull,
|
||||
NlpValuePopulate,
|
||||
} from '../schemas/nlp-value.schema';
|
||||
@ -40,7 +41,7 @@ export class NlpValueRepository extends BaseRepository<
|
||||
*
|
||||
* @param created - The newly created NLP value document.
|
||||
*/
|
||||
async postCreate(created: NlpValue): Promise<void> {
|
||||
async postCreate(created: NlpValueDocument): Promise<void> {
|
||||
if (!created.builtin) {
|
||||
// Bypass builtin entities (probably fixtures)
|
||||
this.eventEmitter.emit('hook:nlpValue:create', created);
|
||||
|
Loading…
Reference in New Issue
Block a user