diff --git a/api/src/eventemitter.d.ts b/api/src/eventemitter.d.ts index d5a2e08..6f07012 100644 --- a/api/src/eventemitter.d.ts +++ b/api/src/eventemitter.d.ts @@ -1,11 +1,11 @@ import { type OnEventOptions } from '@nestjs/event-emitter/dist/interfaces'; -import type { TFilterQuery, HydratedDocument, Query, Document } from 'mongoose'; +import type { Document, HydratedDocument, Query, TFilterQuery } from 'mongoose'; import { type Socket } from 'socket.io'; import { type BotStats } from '@/analytics/schemas/bot-stats.schema'; import { type Attachment } from '@/attachment/schemas/attachment.schema'; import type EventWrapper from '@/channel/lib/EventWrapper'; -import { type Block, BlockFull } from '@/chat/schemas/block.schema'; +import { BlockFull, type Block } from '@/chat/schemas/block.schema'; import { type Category } from '@/chat/schemas/category.schema'; import { type ContextVar } from '@/chat/schemas/context-var.schema'; import { type Conversation } from '@/chat/schemas/conversation.schema'; @@ -64,33 +64,33 @@ declare module '@nestjs/event-emitter' { chatbot_settings: TDefinition< object, { - global_fallback: unknown; - fallback_block: unknown; - fallback_message: unknown; + global_fallback: Setting; + fallback_block: Setting; + fallback_message: Setting; } >; contact: TDefinition< object, { - contact_email_recipient: unknown; - company_name: unknown; - company_phone: unknown; - company_email: unknown; - company_address1: unknown; - company_address2: unknown; - company_city: unknown; - company_zipcode: unknown; - company_state: unknown; - company_country: unknown; + contact_email_recipient: Setting; + company_name: Setting; + company_phone: Setting; + company_email: Setting; + company_address1: Setting; + company_address2: Setting; + company_city: Setting; + company_zipcode: Setting; + company_state: Setting; + company_country: Setting; } >; nlp_settings: TDefinition< object, { - provider: unknown; - endpoint: unknown; - token: unknown; - threshold: number; + provider: Setting; + endpoint: Setting; + token: Setting; + threshold: Setting; } >; } diff --git a/api/src/setting/repositories/setting.repository.ts b/api/src/setting/repositories/setting.repository.ts index 956e8cb..beada31 100644 --- a/api/src/setting/repositories/setting.repository.ts +++ b/api/src/setting/repositories/setting.repository.ts @@ -7,7 +7,10 @@ */ import { Injectable } from '@nestjs/common'; -import { EventEmitter2 } from '@nestjs/event-emitter'; +import { + EventEmitter2, + IHookSettingsGroupLabelOperationMap, +} from '@nestjs/event-emitter'; import { InjectModel } from '@nestjs/mongoose'; import { Document, Model, Query, Types } from 'mongoose'; @@ -78,9 +81,10 @@ export class SettingRepository extends BaseRepository { >, setting: Setting, ) { - const group = setting.group as any; - const label = setting.label as string; + const group = setting.group as keyof IHookSettingsGroupLabelOperationMap; + const label = setting.label as '*'; + // Sync global settings var - this.eventEmitter.emit(`hook:${group}:${label}`, setting as any); + this.eventEmitter.emit(`hook:${group}:${label}`, setting); } }