diff --git a/api/src/eventemitter.d.ts b/api/src/eventemitter.d.ts index 71588244..4d096f54 100644 --- a/api/src/eventemitter.d.ts +++ b/api/src/eventemitter.d.ts @@ -1,33 +1,41 @@ -import { OnEventOptions } from '@nestjs/event-emitter/dist/interfaces'; -import { Socket } from 'socket.io'; +import { type OnEventOptions } from '@nestjs/event-emitter/dist/interfaces'; +import type { TFilterQuery, HydratedDocument, Query, Document } from 'mongoose'; +import { type Socket } from 'socket.io'; -import { BotStats } from '@/analytics/schemas/bot-stats.schema'; -import { Attachment } from '@/attachment/schemas/attachment.schema'; -import { Block, BlockFull } from '@/chat/schemas/block.schema'; -import { Category } from '@/chat/schemas/category.schema'; -import { ContextVar } from '@/chat/schemas/context-var.schema'; -import { Conversation } from '@/chat/schemas/conversation.schema'; -import { Label } from '@/chat/schemas/label.schema'; -import { Message } from '@/chat/schemas/message.schema'; -import { Subscriber } from '@/chat/schemas/subscriber.schema'; -import { ContentType } from '@/cms/schemas/content-type.schema'; -import { Content } from '@/cms/schemas/content.schema'; -import { Menu } from '@/cms/schemas/menu.schema'; -import { Language } from '@/i18n/schemas/language.schema'; -import { Translation } from '@/i18n/schemas/translation.schema'; -import { NlpEntity } from '@/nlp/schemas/nlp-entity.schema'; -import { NlpSampleEntity } from '@/nlp/schemas/nlp-sample-entity.schema'; -import { NlpSample } from '@/nlp/schemas/nlp-sample.schema'; -import { NlpValue } from '@/nlp/schemas/nlp-value.schema'; -import { Setting } from '@/setting/schemas/setting.schema'; -import { Invitation } from '@/user/schemas/invitation.schema'; -import { Model } from '@/user/schemas/model.schema'; -import { Permission } from '@/user/schemas/permission.schema'; -import { Role } from '@/user/schemas/role.schema'; -import { User } from '@/user/schemas/user.schema'; -import { EHook } from '@/utils/generics/base-repository'; +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 { type Category } from '@/chat/schemas/category.schema'; +import { type ContextVar } from '@/chat/schemas/context-var.schema'; +import { type Conversation } from '@/chat/schemas/conversation.schema'; +import { LabelDocument, type Label } from '@/chat/schemas/label.schema'; +import { type Message } from '@/chat/schemas/message.schema'; +import { type Subscriber } from '@/chat/schemas/subscriber.schema'; +import { type ContentType } from '@/cms/schemas/content-type.schema'; +import { type Content } from '@/cms/schemas/content.schema'; +import { type Menu } from '@/cms/schemas/menu.schema'; +import { type Language } from '@/i18n/schemas/language.schema'; +import { type Translation } from '@/i18n/schemas/translation.schema'; +import type { + NlpEntity, + NlpEntityDocument, +} from '@/nlp/schemas/nlp-entity.schema'; +import { type NlpSampleEntity } from '@/nlp/schemas/nlp-sample-entity.schema'; +import { type NlpSample } from '@/nlp/schemas/nlp-sample.schema'; +import { + NlpValueDocument, + type NlpValue, +} from '@/nlp/schemas/nlp-value.schema'; +import { type Setting } from '@/setting/schemas/setting.schema'; +import { type Invitation } from '@/user/schemas/invitation.schema'; +import { type Model } from '@/user/schemas/model.schema'; +import { type Permission } from '@/user/schemas/permission.schema'; +import { type Role } from '@/user/schemas/role.schema'; +import { type User } from '@/user/schemas/user.schema'; +import { EHook, type DeleteResult } from '@/utils/generics/base-repository'; -import { SubscriberUpdateDto } from './chat/dto/subscriber.dto'; +import { type SubscriberUpdateDto } from './chat/dto/subscriber.dto'; import '@nestjs/event-emitter'; @@ -39,21 +47,72 @@ declare module '@nestjs/event-emitter' { schema: S; operations: O; } - interface IHookOperationMap { + + interface IHookExtensionsOperationMap { + messenger_settings: TDefinition< + object, + { + get_started_button: unknown; + access_token: unknown; + composer_input_disabled: unknown; + greeting_text: unknown; + } + >; + } + + interface IHookSettingsGroupLabelOperationMap { + chatbot_settings: TDefinition< + object, + { + global_fallback: unknown; + fallback_block: unknown; + fallback_message: unknown; + } + >; + 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; + } + >; + nlp_settings: TDefinition< + object, + { + provider: unknown; + endpoint: unknown; + token: unknown; + threshold: number; + } + >; + } + + /* custom hooks */ + interface IHookOperationMap + extends IHookSettingsGroupLabelOperationMap, + IHookExtensionsOperationMap { analytics: TDefinition< object, { block: BlockFull; passation: Subscriber; 'fallback-local': BlockFull; - 'fallback-global': any; + 'fallback-global': EventWrapper; } >; chatbot: TDefinition< object, { - sent: unknown; - received: unknown; + sent: string; + received: number; message: unknown; delivery: unknown; read: unknown; @@ -62,7 +121,6 @@ declare module '@nestjs/event-emitter' { echo: unknown; } >; - nlp: TDefinition; websocket: TDefinition< object, { @@ -70,6 +128,8 @@ declare module '@nestjs/event-emitter' { } >; } + + /* entities hooks */ interface IHookEntityOperationMap extends IHookOperationMap { stats: TDefinition; attachment: TDefinition; @@ -79,28 +139,32 @@ declare module '@nestjs/event-emitter' { conversation: TDefinition; label: TDefinition< Label, - { create: THydratedDocument