From 453882b6fd05a744982478e7be03407c7339ee23 Mon Sep 17 00:00:00 2001 From: yassinedorbozgithub Date: Mon, 7 Oct 2024 15:37:08 +0100 Subject: [PATCH] feat(api): eventemitter types definitions --- api/src/eventemitter.d.ts | 247 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 247 insertions(+) create mode 100644 api/src/eventemitter.d.ts diff --git a/api/src/eventemitter.d.ts b/api/src/eventemitter.d.ts new file mode 100644 index 00000000..71588244 --- /dev/null +++ b/api/src/eventemitter.d.ts @@ -0,0 +1,247 @@ +import { OnEventOptions } from '@nestjs/event-emitter/dist/interfaces'; +import { 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 { SubscriberUpdateDto } from './chat/dto/subscriber.dto'; + +import '@nestjs/event-emitter'; + +/** + * @description Module declaration that extends the NestJS EventEmitter with custom event types and methods. + */ +declare module '@nestjs/event-emitter' { + interface TDefinition { + schema: S; + operations: O; + } + interface IHookOperationMap { + analytics: TDefinition< + object, + { + block: BlockFull; + passation: Subscriber; + 'fallback-local': BlockFull; + 'fallback-global': any; + } + >; + chatbot: TDefinition< + object, + { + sent: unknown; + received: unknown; + message: unknown; + delivery: unknown; + read: unknown; + typing: unknown; + follow: unknown; + echo: unknown; + } + >; + nlp: TDefinition; + websocket: TDefinition< + object, + { + connection: Socket; + } + >; + } + interface IHookEntityOperationMap extends IHookOperationMap { + stats: TDefinition; + attachment: TDefinition; + block: TDefinition; + category: TDefinition; + contextVar: TDefinition; + conversation: TDefinition; + label: TDefinition< + Label, + { create: THydratedDocument