@fr-data-fabric/chatbot-api-nest 0.0.4 → 0.0.6
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/dist/chatbot-api.module.d.ts +4 -3
- package/dist/chatbot-api.module.js +3 -3
- package/dist/chatbot-api.module.js.map +1 -1
- package/dist/domain/interfaces/ConversationRepository.d.ts +3 -3
- package/dist/domain/use-cases/conversations/DeleteConversationUC.d.ts +1 -1
- package/dist/domain/use-cases/conversations/DeleteConversationUC.js.map +1 -1
- package/dist/domain/use-cases/conversations/GenerateConversationTitleUC.d.ts +1 -1
- package/dist/domain/use-cases/conversations/GenerateConversationTitleUC.js.map +1 -1
- package/dist/domain/use-cases/conversations/UpdateConversationUC.d.ts +1 -1
- package/dist/domain/use-cases/conversations/UpdateConversationUC.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/chatbot-api.module.ts +13 -8
- package/src/domain/interfaces/ConversationRepository.ts +5 -3
- package/src/domain/use-cases/conversations/DeleteConversationUC.ts +1 -1
- package/src/domain/use-cases/conversations/GenerateConversationTitleUC.ts +1 -1
- package/src/domain/use-cases/conversations/UpdateConversationUC.ts +1 -1
package/package.json
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ConversationEntity } from '@domain/entities/ConversationEntity';
|
|
1
2
|
import { UserEntity } from '@domain/entities/UserEntity';
|
|
2
3
|
import {
|
|
3
4
|
CONVERSATION_REPOSITORY,
|
|
@@ -18,20 +19,23 @@ import {
|
|
|
18
19
|
IGetConversationUC,
|
|
19
20
|
} from '@domain/use-cases/conversations/GetConversationUC';
|
|
20
21
|
import { UpdateConversationUC } from '@domain/use-cases/conversations/UpdateConversationUC';
|
|
22
|
+
import { ChatsController } from '@inputs/controllers/ChatsController';
|
|
23
|
+
import { GetChatsResolver } from '@inputs/resolvers/ChatsResolver';
|
|
24
|
+
import { GetConversationsResolver } from '@inputs/resolvers/ConversationsResolver';
|
|
21
25
|
import { DynamicModule, Module, Type } from '@nestjs/common';
|
|
22
26
|
import { GqlTypeReference } from '@nestjs/graphql';
|
|
23
|
-
import { ChatsController } from 'src/inputs/controllers/ChatsController';
|
|
24
|
-
import { GetChatsResolver } from 'src/inputs/resolvers/ChatsResolver';
|
|
25
|
-
import { GetConversationsResolver } from 'src/inputs/resolvers/ConversationsResolver';
|
|
26
27
|
|
|
27
|
-
export type ChatbotApiModuleOptions<
|
|
28
|
+
export type ChatbotApiModuleOptions<
|
|
29
|
+
TUser extends UserEntity,
|
|
30
|
+
TConversation extends ConversationEntity,
|
|
31
|
+
> = {
|
|
28
32
|
useCases: {
|
|
29
33
|
getConversation: Type<IGetConversationUC<TUser>>;
|
|
30
34
|
getConversations: Type<IGetConversationsUC<TUser>>;
|
|
31
35
|
createConversation: Type<ICreateConversationUC<TUser>>;
|
|
32
36
|
sendChat: Type<SendChatUC<never, TUser>>;
|
|
33
37
|
};
|
|
34
|
-
conversationRepository: Type<ConversationRepository
|
|
38
|
+
conversationRepository: Type<ConversationRepository<TConversation>>;
|
|
35
39
|
gql: {
|
|
36
40
|
GqlConversation: GqlTypeReference;
|
|
37
41
|
GqlChat: GqlTypeReference;
|
|
@@ -44,9 +48,10 @@ export type ChatbotApiModuleOptions<TUser extends UserEntity> = {
|
|
|
44
48
|
|
|
45
49
|
@Module({})
|
|
46
50
|
export class ChatbotApiModule {
|
|
47
|
-
static register<
|
|
48
|
-
|
|
49
|
-
|
|
51
|
+
static register<
|
|
52
|
+
TUser extends UserEntity,
|
|
53
|
+
TConversation extends ConversationEntity,
|
|
54
|
+
>(options: ChatbotApiModuleOptions<TUser, TConversation>): DynamicModule {
|
|
50
55
|
return {
|
|
51
56
|
module: ChatbotApiModule,
|
|
52
57
|
providers: [
|
|
@@ -2,7 +2,9 @@ import { ConversationEntity } from '@domain/entities/ConversationEntity';
|
|
|
2
2
|
|
|
3
3
|
export const CONVERSATION_REPOSITORY = 'ConversationRepository';
|
|
4
4
|
|
|
5
|
-
export interface ConversationRepository
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
export interface ConversationRepository<
|
|
6
|
+
TConversationEntity extends ConversationEntity,
|
|
7
|
+
> {
|
|
8
|
+
save: (conversation: TConversationEntity) => Promise<TConversationEntity>;
|
|
9
|
+
remove: (conversation: TConversationEntity) => Promise<TConversationEntity>;
|
|
8
10
|
}
|
|
@@ -11,7 +11,7 @@ import { Inject, Injectable } from '@nestjs/common';
|
|
|
11
11
|
export class DeleteConversationUC {
|
|
12
12
|
constructor(
|
|
13
13
|
@Inject(CONVERSATION_REPOSITORY)
|
|
14
|
-
private readonly conversationRepository: ConversationRepository
|
|
14
|
+
private readonly conversationRepository: ConversationRepository<ConversationEntity>,
|
|
15
15
|
@Inject(GET_CONVERSATION_UC)
|
|
16
16
|
private readonly getConversationUC: IGetConversationUC<UserEntity>,
|
|
17
17
|
) {}
|
|
@@ -31,7 +31,7 @@ export class GenerateConversationTitleUC {
|
|
|
31
31
|
@Inject(GET_CONVERSATION_UC)
|
|
32
32
|
private readonly getConversationUC: IGetConversationUC<UserEntity>,
|
|
33
33
|
@Inject(CONVERSATION_REPOSITORY)
|
|
34
|
-
private readonly conversationRepository: ConversationRepository
|
|
34
|
+
private readonly conversationRepository: ConversationRepository<ConversationEntity>,
|
|
35
35
|
) {}
|
|
36
36
|
|
|
37
37
|
async execute({
|
|
@@ -24,7 +24,7 @@ export class UpdateConversationInput {
|
|
|
24
24
|
export class UpdateConversationUC {
|
|
25
25
|
constructor(
|
|
26
26
|
@Inject(CONVERSATION_REPOSITORY)
|
|
27
|
-
private readonly conversationRepository: ConversationRepository
|
|
27
|
+
private readonly conversationRepository: ConversationRepository<ConversationEntity>,
|
|
28
28
|
@Inject(GET_CONVERSATION_UC)
|
|
29
29
|
private readonly getConversationUC: IGetConversationUC<UserEntity>,
|
|
30
30
|
) {}
|