@fr-data-fabric/chatbot-api-nest 0.0.8 → 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fr-data-fabric/chatbot-api-nest",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
4
4
  "main": "dist/index.js",
5
5
  "scripts": {
6
6
  "build": "tsc -p tsconfig.json && tsc-alias -p tsconfig.json"
@@ -1,4 +1,9 @@
1
+ import { ConversationEntity } from '@domain/entities/ConversationEntity';
1
2
  import { UserEntity } from '@domain/entities/UserEntity';
3
+ import {
4
+ CONVERSATION_REPOSITORY,
5
+ ConversationRepository,
6
+ } from '@domain/interfaces/ConversationRepository';
2
7
  import { SEND_CHAT_UC, SendChatUC } from '@domain/use-cases/chats/SendChatUC';
3
8
  import {
4
9
  CREATE_CONVERSATION_UC,
@@ -17,16 +22,22 @@ import { UpdateConversationUC } from '@domain/use-cases/conversations/UpdateConv
17
22
  import { ChatsController } from '@inputs/controllers/ChatsController';
18
23
  import { GetChatsResolver } from '@inputs/resolvers/ChatsResolver';
19
24
  import { GetConversationsResolver } from '@inputs/resolvers/ConversationsResolver';
20
- import { DynamicModule, Module, Type } from '@nestjs/common';
25
+ import { DynamicModule, Module, Provider, Type } from '@nestjs/common';
21
26
  import { GqlTypeReference } from '@nestjs/graphql';
22
27
 
23
- export type ChatbotApiModuleOptions<TUser extends UserEntity> = {
28
+ export type ChatbotApiModuleOptions<
29
+ TUser extends UserEntity,
30
+ TConversation extends ConversationEntity,
31
+ > = {
32
+ imports?: DynamicModule[];
33
+ providers?: Provider[];
24
34
  useCases: {
25
35
  getConversation: Type<IGetConversationUC<TUser>>;
26
36
  getConversations: Type<IGetConversationsUC<TUser>>;
27
37
  createConversation: Type<ICreateConversationUC<TUser>>;
28
38
  sendChat: Type<SendChatUC<never, TUser>>;
29
39
  };
40
+ conversationRepository: Type<ConversationRepository<TConversation>>;
30
41
  gql: {
31
42
  GqlConversation: GqlTypeReference;
32
43
  GqlChat: GqlTypeReference;
@@ -39,12 +50,20 @@ export type ChatbotApiModuleOptions<TUser extends UserEntity> = {
39
50
 
40
51
  @Module({})
41
52
  export class ChatbotApiModule {
42
- static register<TUser extends UserEntity>(
43
- options: ChatbotApiModuleOptions<TUser>,
44
- ): DynamicModule {
53
+ static register<
54
+ TUser extends UserEntity,
55
+ TConversation extends ConversationEntity,
56
+ >(options: ChatbotApiModuleOptions<TUser, TConversation>): DynamicModule {
45
57
  return {
58
+ imports: options.imports || [],
46
59
  module: ChatbotApiModule,
47
60
  providers: [
61
+ ...(options.providers || []),
62
+ // Repositories
63
+ {
64
+ provide: CONVERSATION_REPOSITORY,
65
+ useClass: options.conversationRepository,
66
+ },
48
67
  // Use cases
49
68
  {
50
69
  provide: GET_CONVERSATION_UC,