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

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.9",
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,
@@ -20,13 +25,18 @@ import { GetConversationsResolver } from '@inputs/resolvers/ConversationsResolve
20
25
  import { DynamicModule, Module, 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[];
24
33
  useCases: {
25
34
  getConversation: Type<IGetConversationUC<TUser>>;
26
35
  getConversations: Type<IGetConversationsUC<TUser>>;
27
36
  createConversation: Type<ICreateConversationUC<TUser>>;
28
37
  sendChat: Type<SendChatUC<never, TUser>>;
29
38
  };
39
+ conversationRepository: Type<ConversationRepository<TConversation>>;
30
40
  gql: {
31
41
  GqlConversation: GqlTypeReference;
32
42
  GqlChat: GqlTypeReference;
@@ -39,12 +49,19 @@ export type ChatbotApiModuleOptions<TUser extends UserEntity> = {
39
49
 
40
50
  @Module({})
41
51
  export class ChatbotApiModule {
42
- static register<TUser extends UserEntity>(
43
- options: ChatbotApiModuleOptions<TUser>,
44
- ): DynamicModule {
52
+ static register<
53
+ TUser extends UserEntity,
54
+ TConversation extends ConversationEntity,
55
+ >(options: ChatbotApiModuleOptions<TUser, TConversation>): DynamicModule {
45
56
  return {
57
+ imports: options.imports || [],
46
58
  module: ChatbotApiModule,
47
59
  providers: [
60
+ // Repositories
61
+ {
62
+ provide: CONVERSATION_REPOSITORY,
63
+ useClass: options.conversationRepository,
64
+ },
48
65
  // Use cases
49
66
  {
50
67
  provide: GET_CONVERSATION_UC,