@wabot-dev/framework 0.1.0-beta.65 → 0.1.0-beta.67

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.
@@ -1,6 +1,7 @@
1
1
  import { container } from '../../../core/injection/index.js';
2
2
  import { ControllerMetadataStore } from '../../../feature/chat-controller/metadata/ControllerMetadataStore.js';
3
3
  import '../../../feature/chat-controller/ChatResolver.js';
4
+ import '../../../core/auth/Auth.js';
4
5
  import '../../../feature/chat-bot/ChatBot.js';
5
6
  import 'uuid';
6
7
  import '../../../feature/chat-bot/metadata/ChatBotMetadataStore.js';
@@ -1,6 +1,7 @@
1
1
  import { container } from '../../../core/injection/index.js';
2
2
  import { ControllerMetadataStore } from '../../../feature/chat-controller/metadata/ControllerMetadataStore.js';
3
3
  import '../../../feature/chat-controller/ChatResolver.js';
4
+ import '../../../core/auth/Auth.js';
4
5
  import '../../../feature/chat-bot/ChatBot.js';
5
6
  import 'uuid';
6
7
  import '../../../feature/chat-bot/metadata/ChatBotMetadataStore.js';
@@ -46,6 +46,10 @@ let SocketChannel = SocketChannel_1 = class SocketChannel {
46
46
  reply: (message) => {
47
47
  socket.emit(this.config.channel, message);
48
48
  },
49
+ authInfo: socket.data.authInfo,
50
+ setAuthInfo: (authInfo) => {
51
+ socket.data.authInfo = authInfo;
52
+ },
49
53
  });
50
54
  });
51
55
  });
@@ -1,6 +1,7 @@
1
1
  import { container } from '../../../core/injection/index.js';
2
2
  import { ControllerMetadataStore } from '../../../feature/chat-controller/metadata/ControllerMetadataStore.js';
3
3
  import '../../../feature/chat-controller/ChatResolver.js';
4
+ import '../../../core/auth/Auth.js';
4
5
  import '../../../feature/chat-bot/ChatBot.js';
5
6
  import 'uuid';
6
7
  import '../../../feature/chat-bot/metadata/ChatBotMetadataStore.js';
@@ -2,6 +2,7 @@ import { container } from '../../../core/injection/index.js';
2
2
  import { WhatsappChannelConfig } from './WhatsAppChannelConfig.js';
3
3
  import { ControllerMetadataStore } from '../../../feature/chat-controller/metadata/ControllerMetadataStore.js';
4
4
  import '../../../feature/chat-controller/ChatResolver.js';
5
+ import '../../../core/auth/Auth.js';
5
6
  import '../../../feature/chat-bot/ChatBot.js';
6
7
  import 'uuid';
7
8
  import '../../../feature/chat-bot/metadata/ChatBotMetadataStore.js';
@@ -4,6 +4,7 @@ import { WhatsAppSender } from '../WhatsAppSender.js';
4
4
  import { singleton } from '../../../../core/injection/index.js';
5
5
  import '../../../../feature/chat-controller/metadata/ControllerMetadataStore.js';
6
6
  import { ChatResolver } from '../../../../feature/chat-controller/ChatResolver.js';
7
+ import '../../../../core/auth/Auth.js';
7
8
  import '../../../../feature/chat-bot/ChatBot.js';
8
9
  import { ChatRepository } from '../../../../feature/chat-bot/ChatRepository.js';
9
10
  import 'uuid';
@@ -8,6 +8,7 @@ import 'uuid';
8
8
  import '../../../../feature/chat-bot/metadata/ChatBotMetadataStore.js';
9
9
  import '../../../../feature/chat-controller/metadata/ControllerMetadataStore.js';
10
10
  import { ChatResolver } from '../../../../feature/chat-controller/ChatResolver.js';
11
+ import '../../../../core/auth/Auth.js';
11
12
  import 'reflect-metadata';
12
13
  import '../../../../feature/mindset/metadata/MindsetMetadataStore.js';
13
14
  import '../../../../feature/mindset/MindsetOperator.js';
@@ -1,3 +1,4 @@
1
+ import { Auth } from '../../core/auth/Auth.js';
1
2
  import { container } from '../../core/injection/index.js';
2
3
  import { Chat } from '../chat-bot/Chat.js';
3
4
  import { ChatBot } from '../chat-bot/ChatBot.js';
@@ -23,6 +24,10 @@ async function prepareChatContainer(container, messageContext, mindsetCtor) {
23
24
  throw new Error('Not found Chat Memory for Chat with Id=' + messageContext.chat.id);
24
25
  }
25
26
  chatContainer.registerInstance(ChatMemory, chatMemory);
27
+ if (messageContext.authInfo) {
28
+ const auth = chatContainer.resolve(Auth);
29
+ auth.assign(messageContext.authInfo);
30
+ }
26
31
  const chatBotMetadataStore = container.resolve(ChatBotMetadataStore);
27
32
  const chatBots = chatBotMetadataStore.getChatBotsMetadata();
28
33
  for (const chatBotMetadata of chatBots) {
@@ -55,11 +60,20 @@ function runChatControllers(controllers) {
55
60
  const chat = await chatResolver.resolve(channelMessage.chatConnection);
56
61
  const chatContainer = await prepareChatContainer(channelContainer, {
57
62
  chat,
58
- message: channelMessage.message,
59
- reply: channelMessage.reply,
63
+ ...channelMessage,
60
64
  });
61
65
  const chatController = chatContainer.resolve(channelMetadata.controllerConstructor);
62
- chatController[channelMetadata.functionName](channelMessage);
66
+ const receivedMessage = {
67
+ message: channelMessage.message,
68
+ reply: (message) => {
69
+ channelMessage.reply(message);
70
+ if (channelMessage.setAuthInfo) {
71
+ const auth = chatContainer.resolve(Auth);
72
+ channelMessage.setAuthInfo(auth['authInfo'] || undefined);
73
+ }
74
+ },
75
+ };
76
+ chatController[channelMetadata.functionName](receivedMessage);
63
77
  });
64
78
  channel.connect();
65
79
  }
@@ -698,6 +698,8 @@ interface IReceivedMessage {
698
698
 
699
699
  interface IChannelMessage extends IReceivedMessage {
700
700
  chatConnection: IChatConnection;
701
+ authInfo?: IStorableData;
702
+ setAuthInfo?: (authInfo: IStorableData | undefined) => void;
701
703
  }
702
704
 
703
705
  interface IChatChannel {
@@ -733,6 +735,7 @@ declare class ChatResolver {
733
735
 
734
736
  interface IMessageContext extends IReceivedMessage {
735
737
  chat: Chat;
738
+ authInfo?: IStorableData;
736
739
  }
737
740
 
738
741
  declare function runChatControllers(controllers: IConstructor<any>[]): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wabot-dev/framework",
3
- "version": "0.1.0-beta.65",
3
+ "version": "0.1.0-beta.67",
4
4
  "description": "Framework for IA Chat Bots",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",