mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
feat: implement strict null check
This commit is contained in:
@@ -109,7 +109,7 @@ describe('NlpEntityController', () => {
|
||||
acc.push({
|
||||
...curr,
|
||||
values: nlpValueFixtures.filter(
|
||||
({ entity }) => parseInt(entity) === index,
|
||||
({ entity }) => parseInt(entity!) === index,
|
||||
) as NlpEntityFull['values'],
|
||||
lookups: curr.lookups!,
|
||||
builtin: curr.builtin!,
|
||||
|
||||
@@ -98,7 +98,7 @@ describe('NlpValueController', () => {
|
||||
acc.push({
|
||||
...curr,
|
||||
entity: nlpEntityFixtures[
|
||||
parseInt(curr.entity)
|
||||
parseInt(curr.entity!)
|
||||
] as NlpValueFull['entity'],
|
||||
builtin: curr.builtin!,
|
||||
expressions: curr.expressions!,
|
||||
@@ -125,7 +125,7 @@ describe('NlpValueController', () => {
|
||||
(acc, curr) => {
|
||||
const ValueWithEntities = {
|
||||
...curr,
|
||||
entity: nlpEntities[parseInt(curr.entity)].id,
|
||||
entity: nlpEntities[parseInt(curr.entity!)].id,
|
||||
expressions: curr.expressions!,
|
||||
metadata: curr.metadata!,
|
||||
builtin: curr.builtin!,
|
||||
|
||||
@@ -75,8 +75,9 @@ export class NlpValueController extends BaseController<
|
||||
this.validate({
|
||||
dto: createNlpValueDto,
|
||||
allowedIds: {
|
||||
entity: (await this.nlpEntityService.findOne(createNlpValueDto.entity))
|
||||
?.id,
|
||||
entity: createNlpValueDto.entity
|
||||
? (await this.nlpEntityService.findOne(createNlpValueDto.entity))?.id
|
||||
: null,
|
||||
},
|
||||
});
|
||||
return await this.nlpValueService.create(createNlpValueDto);
|
||||
@@ -167,7 +168,10 @@ export class NlpValueController extends BaseController<
|
||||
@Param('id') id: string,
|
||||
@Body() updateNlpValueDto: NlpValueUpdateDto,
|
||||
): Promise<NlpValue> {
|
||||
const result = await this.nlpValueService.updateOne(id, updateNlpValueDto);
|
||||
const result = await this.nlpValueService.updateOne(id, {
|
||||
...updateNlpValueDto,
|
||||
entity: updateNlpValueDto.entity || undefined,
|
||||
});
|
||||
if (!result) {
|
||||
this.logger.warn(`Unable to update NLP Value by id ${id}`);
|
||||
throw new NotFoundException(`NLP Value with ID ${id} not found`);
|
||||
|
||||
Reference in New Issue
Block a user