@wabot-dev/framework 0.1.0-beta.29 → 0.1.0-beta.30
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/src/addon/async/pg/PgJobRepository.js +26 -0
- package/dist/src/addon/chat-bot/claude/ClaudeChatBotAdapter.js +107 -0
- package/dist/src/addon/chat-bot/deepseek/DeepSeekChatBotAdapter.js +103 -0
- package/dist/src/{ai → addon/chat-bot}/openia/OpenaiChatAdapter.js +3 -3
- package/dist/src/{pre-made/repository/chat → addon/chat-bot}/pg/PgChatMemory.js +5 -4
- package/dist/src/{pre-made/repository/chat → addon/chat-bot}/pg/PgChatRepository.js +5 -5
- package/dist/src/{pre-made/repository/chat → addon/chat-bot}/ram/RamChatRepository.js +1 -1
- package/dist/src/addon/chat-controller/cmd/@cmd.js +22 -0
- package/dist/src/{channels → addon/chat-controller}/cmd/CmdChannel.js +5 -27
- package/dist/src/{channels → addon/chat-controller}/socket/@socket.js +8 -4
- package/dist/src/{channels → addon/chat-controller}/socket/SocketChannel.js +6 -24
- package/dist/src/{channels → addon/chat-controller}/socket/SocketChannelConfig.js +1 -1
- package/dist/src/{channels → addon/chat-controller}/telegram/@telegram.js +8 -4
- package/dist/src/{channels → addon/chat-controller}/telegram/TelegramChannel.js +5 -23
- package/dist/src/{channels → addon/chat-controller}/whatsapp/@whatsapp.js +8 -4
- package/dist/src/{channels → addon/chat-controller}/whatsapp/EnvWhatsAppRepository.js +2 -2
- package/dist/src/{channels → addon/chat-controller}/whatsapp/PgWhatsAppRepository.js +1 -1
- package/dist/src/{channels/wabot → addon/chat-controller/whatsapp}/WabotDevConnection.js +2 -2
- package/dist/src/{channels → addon/chat-controller}/whatsapp/WhatsApp.js +1 -3
- package/dist/src/{channels → addon/chat-controller}/whatsapp/WhatsAppChannel.js +6 -18
- package/dist/src/{channels → addon/chat-controller}/whatsapp/WhatsAppReceiver.js +13 -10
- package/dist/src/{channels → addon/chat-controller}/whatsapp/WhatsAppReceiverByDevConnection.js +3 -9
- package/dist/src/{channels → addon/chat-controller}/whatsapp/WhatsAppReceiverByWebHook.js +2 -9
- package/dist/src/{channels → addon/chat-controller}/whatsapp/WhatsAppSender.js +12 -7
- package/dist/src/{channels → addon/chat-controller}/whatsapp/WhatsAppSenderByCloudApi.js +10 -7
- package/dist/src/{channels → addon/chat-controller}/whatsapp/WhatsAppSenderByDevConnection.js +12 -9
- package/dist/src/{pre-made/module → addon/mindset}/html/HtmlModule.js +6 -6
- package/dist/src/{repository → addon/repository}/pg/PgCrudRepository.js +1 -1
- package/dist/src/addon/rest-controller/jwt/@jwtGuard.js +17 -0
- package/dist/src/{jwt → addon/rest-controller/jwt}/Jwt.js +7 -2
- package/dist/src/{jwt → addon/rest-controller/jwt}/JwtAccessAndRefreshTokenDto.js +3 -3
- package/dist/src/{jwt → addon/rest-controller/jwt}/JwtConfig.js +2 -2
- package/dist/src/{jwt → addon/rest-controller/jwt}/JwtGuardMiddleware.js +8 -3
- package/dist/src/addon/rest-controller/jwt/JwtRefreshToken.js +9 -0
- package/dist/src/{jwt → addon/rest-controller/jwt}/JwtRefreshTokenRepository.js +2 -2
- package/dist/src/{jwt → addon/rest-controller/jwt}/JwtSigner.js +2 -2
- package/dist/src/{jwt → addon/rest-controller/jwt}/JwtTokenDto.js +5 -5
- package/dist/src/{validation/metadata → addon/validation/is-boolean}/@isBoolean.js +3 -3
- package/dist/src/{validation/metadata → addon/validation/is-date}/@isDate.js +3 -3
- package/dist/src/{validation/metadata → addon/validation/is-not-empty}/@isNotEmpty.js +3 -3
- package/dist/src/{validation/metadata → addon/validation/is-number}/@isNumber.js +3 -3
- package/dist/src/{validation/metadata → addon/validation/is-present}/@isPresent.js +3 -3
- package/dist/src/{validation/metadata → addon/validation/is-string}/@isString.js +3 -3
- package/dist/src/{validation/metadata → addon/validation/max}/@max.js +3 -3
- package/dist/src/{validation/metadata → addon/validation/min}/@min.js +3 -3
- package/dist/src/core/{Entity.js → entity/Entity.js} +1 -1
- package/dist/src/{mapper → core/mapper}/Mapper.js +1 -3
- package/dist/src/{async → feature/async}/@command.js +1 -1
- package/dist/src/{async → feature/async}/@commandHandler.js +1 -1
- package/dist/src/{async → feature/async}/Async.js +1 -1
- package/dist/src/feature/async/Command.js +9 -0
- package/dist/src/{async → feature/async}/CommandMetadataStore.js +1 -1
- package/dist/src/{async → feature/async}/Job.js +2 -4
- package/dist/src/feature/async/JobRepository.js +31 -0
- package/dist/src/{async → feature/async}/JobRunner.js +1 -1
- package/dist/src/{async → feature/async}/JobsEventsHub.js +1 -1
- package/dist/src/{async → feature/async}/runCommandHandlers.js +1 -1
- package/dist/src/{core/chat → feature/chat-bot}/Chat.js +1 -1
- package/dist/src/feature/chat-bot/ChatAdapter.js +7 -0
- package/dist/src/feature/chat-bot/ChatBot.js +50 -0
- package/dist/src/feature/chat-bot/ChatItem.js +24 -0
- package/dist/src/feature/chat-bot/ChatMemory.js +10 -0
- package/dist/src/{core/chat/repository/IChatRepository.js → feature/chat-bot/ChatRepository.js} +2 -8
- package/dist/src/feature/chat-bot/IChatItem.js +3 -0
- package/dist/src/{chatbot → feature/chat-bot}/metadata/@chatBot.js +1 -1
- package/dist/src/{chatbot → feature/chat-bot}/metadata/ChatBotMetadataStore.js +1 -1
- package/dist/src/{controller/channel → feature/chat-controller}/ChatResolver.js +5 -4
- package/dist/src/{controller → feature/chat-controller}/metadata/ControllerMetadataStore.js +1 -1
- package/dist/src/{controller → feature/chat-controller}/metadata/controller/@chatController.js +1 -1
- package/dist/src/feature/chat-controller/runChatControllers.js +69 -0
- package/dist/src/{channels → feature}/express/ExpressProvider.js +1 -1
- package/dist/src/{channels → feature}/http/HttpServerProvider.js +1 -1
- package/dist/src/{mindset → feature/mindset}/MindsetOperator.js +2 -61
- package/dist/src/{mindset → feature/mindset}/metadata/MindsetMetadataStore.js +1 -1
- package/dist/src/{mindset → feature/mindset}/metadata/functions/@mindsetFunction.js +1 -1
- package/dist/src/{mindset → feature/mindset}/metadata/mindsets/@mindset.js +1 -1
- package/dist/src/{mindset → feature/mindset}/metadata/modules/@mindsetModule.js +1 -2
- package/dist/src/{mindset → feature/mindset}/metadata/params/@param.js +1 -1
- package/dist/src/{auth → feature/rest-controller/auth}/Auth.js +2 -2
- package/dist/src/{rest-controller → feature/rest-controller}/metadata/@get.js +1 -1
- package/dist/src/{rest-controller → feature/rest-controller}/metadata/@middleware.js +1 -1
- package/dist/src/{rest-controller → feature/rest-controller}/metadata/@post.js +1 -1
- package/dist/src/{rest-controller → feature/rest-controller}/metadata/@restController.js +1 -1
- package/dist/src/{rest-controller → feature/rest-controller}/metadata/RestControllerMetadataStore.js +1 -1
- package/dist/src/{rest-controller → feature/rest-controller}/runRestControllers.js +6 -24
- package/dist/src/{channels → feature}/socket/SocketServerProvider.js +1 -1
- package/dist/src/index.d.ts +550 -724
- package/dist/src/index.js +118 -133
- package/package.json +1 -1
- package/dist/src/ai/claude/ClaudeChatBotAdapter.js +0 -112
- package/dist/src/ai/deepseek/DeepSeekChatBotAdapter.js +0 -107
- package/dist/src/ai/openia/OpenaiChatBotAdapter.js +0 -88
- package/dist/src/async/Command.js +0 -11
- package/dist/src/async/JobRepository.js +0 -21
- package/dist/src/channels/cmd/@cmd.js +0 -18
- package/dist/src/chatbot/ChatBot.js +0 -50
- package/dist/src/chatbot/ChatBotAdapter.js +0 -70
- package/dist/src/controller/channel/UserResolver.js +0 -21
- package/dist/src/core/IMessageContext.js +0 -12
- package/dist/src/core/chat/ChatItem.js +0 -15
- package/dist/src/core/chat/IChatAdapter.js +0 -3
- package/dist/src/core/chat/repository/IChatMemory.js +0 -10
- package/dist/src/core/user/IUserRepository.js +0 -19
- package/dist/src/core/user/User.js +0 -26
- package/dist/src/jwt/@jwtGuard.js +0 -34
- package/dist/src/jwt/JwtRefreshToken.js +0 -11
- package/dist/src/pre-made/module/authentication/AuthenticationModule.js +0 -97
- package/dist/src/pre-made/module/authentication/requests/SendOneTimePasswordRequest.js +0 -25
- package/dist/src/pre-made/module/authentication/requests/ValidateOneTimePasswordRequest.js +0 -25
- package/dist/src/pre-made/module/register-user/RegisterUserModule.js +0 -56
- package/dist/src/pre-made/module/register-user/requests/RegisterUserWithEmailRequest.js +0 -25
- package/dist/src/pre-made/repository/user/pg/PgUserRepository.js +0 -33
- package/dist/src/pre-made/repository/user/ram/RamUserRepository.js +0 -27
- package/dist/src/pre-made/service/EmailService.js +0 -13
- package/dist/src/pre-made/service/OtpService.js +0 -14
- package/dist/src/server/prepareChatContainer.js +0 -43
- package/dist/src/server/runChannel.js +0 -27
- package/dist/src/server/runServer.js +0 -40
- /package/dist/src/{pre-made/repository/chat → addon/chat-bot}/ram/RamChatMemory.js +0 -0
- /package/dist/src/{channels → addon/chat-controller}/telegram/TelegramChannelConfig.js +0 -0
- /package/dist/src/{channels/wabot → addon/chat-controller/whatsapp}/WabotDevSocketContracts.js +0 -0
- /package/dist/src/{channels → addon/chat-controller}/whatsapp/WhatsAppChannelConfig.js +0 -0
- /package/dist/src/{channels → addon/chat-controller}/whatsapp/WhatsAppRepository.js +0 -0
- /package/dist/src/{repository → addon/repository}/pg/PgRepositoryBase.js +0 -0
- /package/dist/src/{validation/validators → addon/validation/is-boolean}/validateIsBoolean.js +0 -0
- /package/dist/src/{validation/validators → addon/validation/is-date}/validateIsDate.js +0 -0
- /package/dist/src/{validation/validators → addon/validation/is-not-empty}/validateIsNotEmpty.js +0 -0
- /package/dist/src/{validation/validators → addon/validation/is-number}/validateIsNumber.js +0 -0
- /package/dist/src/{validation/validators → addon/validation/is-present}/validateIsPresent.js +0 -0
- /package/dist/src/{validation/validators → addon/validation/is-string}/validateIsString.js +0 -0
- /package/dist/src/{validation/validators → addon/validation/max}/validateMax.js +0 -0
- /package/dist/src/{validation/validators → addon/validation/min}/validateMin.js +0 -0
- /package/dist/src/{env → core/env}/Env.js +0 -0
- /package/dist/src/{error → core/error}/CustomError.js +0 -0
- /package/dist/src/{injection → core/injection}/Container.js +0 -0
- /package/dist/src/{injection → core/injection}/index.js +0 -0
- /package/dist/src/{logger → core/logger}/Logger.js +0 -0
- /package/dist/src/{random → core/random}/Random.js +0 -0
- /package/dist/src/core/{Storable.js → storable/Storable.js} +0 -0
- /package/dist/src/{validation → core/validation}/metadata/@isArray.js +0 -0
- /package/dist/src/{validation → core/validation}/metadata/@isModel.js +0 -0
- /package/dist/src/{validation → core/validation}/metadata/@isOptional.js +0 -0
- /package/dist/src/{validation → core/validation}/metadata/ValidationMetadataStore.js +0 -0
- /package/dist/src/{validation → core/validation}/modelInfo.js +0 -0
- /package/dist/src/{validation → core/validation}/validate.js +0 -0
- /package/dist/src/{validation → core/validation}/validators/validateArray.js +0 -0
- /package/dist/src/{validation → core/validation}/validators/validateIsOptional.js +0 -0
- /package/dist/src/{validation → core/validation}/validators/validateModel.js +0 -0
- /package/dist/src/{mindset → feature/mindset}/IMindset.js +0 -0
- /package/dist/src/{mindset → feature/mindset}/metadata/functions/decoratorNames.js +0 -0
- /package/dist/src/{mindset → feature/mindset}/metadata/mindsets/decoratorNames.js +0 -0
- /package/dist/src/{mindset → feature/mindset}/metadata/modules/decoratorNames.js +0 -0
- /package/dist/src/{mindset → feature/mindset}/metadata/params/decoratorNames.js +0 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ChatItem } from './ChatItem.js';
|
|
2
|
+
|
|
3
|
+
class ChatBot {
|
|
4
|
+
memory;
|
|
5
|
+
adapter;
|
|
6
|
+
mindset;
|
|
7
|
+
constructor(memory, adapter, mindset) {
|
|
8
|
+
this.memory = memory;
|
|
9
|
+
this.adapter = adapter;
|
|
10
|
+
this.mindset = mindset;
|
|
11
|
+
}
|
|
12
|
+
async sendMessage(message, callback) {
|
|
13
|
+
const newChatItem = new ChatItem({
|
|
14
|
+
type: 'humanMessage',
|
|
15
|
+
humanMessage: message,
|
|
16
|
+
});
|
|
17
|
+
await this.memory.create(newChatItem);
|
|
18
|
+
this.processLoop(callback);
|
|
19
|
+
}
|
|
20
|
+
async processLoop(callback) {
|
|
21
|
+
const prevItems = await this.memory.findLastItems(10);
|
|
22
|
+
if (prevItems.length === 0) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const lastChatItem = prevItems[prevItems.length - 1];
|
|
26
|
+
if (lastChatItem.type === 'botMessage') {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const systemPrompt = await this.mindset.systemPrompt();
|
|
30
|
+
const tools = this.mindset.tools();
|
|
31
|
+
const newItemData = await this.adapter.nextItem({
|
|
32
|
+
model: 'gpt',
|
|
33
|
+
systemPrompt,
|
|
34
|
+
tools,
|
|
35
|
+
prevItems: prevItems.map((x) => x.getData()),
|
|
36
|
+
});
|
|
37
|
+
if (newItemData.type === 'functionCall') {
|
|
38
|
+
newItemData.functionCall.result = await this.mindset.callFunction(newItemData.functionCall.name, newItemData.functionCall.arguments ?? '{}');
|
|
39
|
+
}
|
|
40
|
+
const newChatItem = new ChatItem(newItemData);
|
|
41
|
+
await this.memory.create(newChatItem);
|
|
42
|
+
if (newChatItem.type === 'botMessage') {
|
|
43
|
+
callback(newChatItem.botMessage);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
this.processLoop(callback);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export { ChatBot };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Entity } from '../../core/entity/Entity.js';
|
|
2
|
+
|
|
3
|
+
class ChatItem extends Entity {
|
|
4
|
+
get type() {
|
|
5
|
+
return this.data.type;
|
|
6
|
+
}
|
|
7
|
+
get botMessage() {
|
|
8
|
+
return this.data.botMessage;
|
|
9
|
+
}
|
|
10
|
+
get functionCall() {
|
|
11
|
+
return this.data.functionCall;
|
|
12
|
+
}
|
|
13
|
+
setFunctionResult(result) {
|
|
14
|
+
if (this.data.type !== 'functionCall') {
|
|
15
|
+
throw new Error('The chat item is not functionCall type');
|
|
16
|
+
}
|
|
17
|
+
this.data.functionCall.result = result;
|
|
18
|
+
}
|
|
19
|
+
getData() {
|
|
20
|
+
return this.data;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export { ChatItem };
|
package/dist/src/{core/chat/repository/IChatRepository.js → feature/chat-bot/ChatRepository.js}
RENAMED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import { singleton } from '../../../injection/index.js';
|
|
3
|
-
|
|
4
|
-
let ChatRepository = class ChatRepository {
|
|
1
|
+
class ChatRepository {
|
|
5
2
|
create(chat) {
|
|
6
3
|
throw new Error('Method not implemented.');
|
|
7
4
|
}
|
|
@@ -11,9 +8,6 @@ let ChatRepository = class ChatRepository {
|
|
|
11
8
|
findMemory(chatId) {
|
|
12
9
|
throw new Error('Method not implemented.');
|
|
13
10
|
}
|
|
14
|
-
}
|
|
15
|
-
ChatRepository = __decorate([
|
|
16
|
-
singleton()
|
|
17
|
-
], ChatRepository);
|
|
11
|
+
}
|
|
18
12
|
|
|
19
13
|
export { ChatRepository };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { __decorate, __metadata } from 'tslib';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import '../../core/
|
|
5
|
-
import
|
|
2
|
+
import { Chat } from '../chat-bot/Chat.js';
|
|
3
|
+
import { ChatRepository } from '../chat-bot/ChatRepository.js';
|
|
4
|
+
import { injectable } from '../../core/injection/index.js';
|
|
5
|
+
import 'uuid';
|
|
6
|
+
import '../chat-bot/metadata/ChatBotMetadataStore.js';
|
|
6
7
|
|
|
7
8
|
let ChatResolver = class ChatResolver {
|
|
8
9
|
chatRepository;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { container } from '../../core/injection/index.js';
|
|
2
|
+
import { Chat } from '../chat-bot/Chat.js';
|
|
3
|
+
import { ChatBot } from '../chat-bot/ChatBot.js';
|
|
4
|
+
import { ChatMemory } from '../chat-bot/ChatMemory.js';
|
|
5
|
+
import { ChatRepository } from '../chat-bot/ChatRepository.js';
|
|
6
|
+
import 'uuid';
|
|
7
|
+
import { ChatBotMetadataStore } from '../chat-bot/metadata/ChatBotMetadataStore.js';
|
|
8
|
+
import 'reflect-metadata';
|
|
9
|
+
import '../mindset/metadata/MindsetMetadataStore.js';
|
|
10
|
+
import { Mindset } from '../mindset/IMindset.js';
|
|
11
|
+
import '../mindset/MindsetOperator.js';
|
|
12
|
+
import { ChatResolver } from './ChatResolver.js';
|
|
13
|
+
import { ControllerMetadataStore } from './metadata/ControllerMetadataStore.js';
|
|
14
|
+
import { Container } from '../../core/injection/Container.js';
|
|
15
|
+
|
|
16
|
+
async function prepareChatContainer(container, messageContext, mindsetCtor) {
|
|
17
|
+
const chatContainer = container.createChildContainer();
|
|
18
|
+
chatContainer.register(Container, { useValue: chatContainer });
|
|
19
|
+
chatContainer.registerInstance(Chat, messageContext.chat);
|
|
20
|
+
const chatRepository = container.resolve(ChatRepository);
|
|
21
|
+
const chatMemory = await chatRepository.findMemory(messageContext.chat.id);
|
|
22
|
+
if (!chatMemory) {
|
|
23
|
+
throw new Error('Not found Chat Memory for Chat with Id=' + messageContext.chat.id);
|
|
24
|
+
}
|
|
25
|
+
chatContainer.registerInstance(ChatMemory, chatMemory);
|
|
26
|
+
const chatBotMetadataStore = container.resolve(ChatBotMetadataStore);
|
|
27
|
+
const chatBots = chatBotMetadataStore.getChatBotsMetadata();
|
|
28
|
+
for (const chatBotMetadata of chatBots) {
|
|
29
|
+
chatContainer.beforeResolution(chatBotMetadata.constructor, (a, b) => {
|
|
30
|
+
const subContainer = chatContainer.createChildContainer();
|
|
31
|
+
subContainer.register(Mindset, { useClass: chatBotMetadata.mindsetConstructor });
|
|
32
|
+
const chatBot = subContainer.resolve(ChatBot);
|
|
33
|
+
chatContainer.register(chatBotMetadata.injectionToken, { useValue: chatBot });
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return chatContainer;
|
|
37
|
+
}
|
|
38
|
+
function runChatControllers(controllers) {
|
|
39
|
+
const metadataStore = container.resolve(ControllerMetadataStore);
|
|
40
|
+
const chatResolver = container.resolve(ChatResolver);
|
|
41
|
+
for (const controllerCtor of controllers) {
|
|
42
|
+
const chatControllerMetadata = metadataStore.getChatControllerMetadata(controllerCtor);
|
|
43
|
+
if (!chatControllerMetadata) {
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
for (const channelMetadata of chatControllerMetadata.channels) {
|
|
47
|
+
const channelContainer = container.createChildContainer();
|
|
48
|
+
if (channelMetadata.channelConfig) {
|
|
49
|
+
channelContainer.register(channelMetadata.channelConfig.constructor, {
|
|
50
|
+
useValue: channelMetadata.channelConfig,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
const channel = channelContainer.resolve(channelMetadata.channelConstructor);
|
|
54
|
+
channel.listen(async (channelMessage) => {
|
|
55
|
+
const chat = await chatResolver.resolve(channelMessage.chatConnection);
|
|
56
|
+
const chatContainer = await prepareChatContainer(channelContainer, {
|
|
57
|
+
chat,
|
|
58
|
+
message: channelMessage.message,
|
|
59
|
+
reply: channelMessage.reply,
|
|
60
|
+
});
|
|
61
|
+
const chatController = chatContainer.resolve(channelMetadata.controllerConstructor);
|
|
62
|
+
chatController[channelMetadata.functionName](channelMessage);
|
|
63
|
+
});
|
|
64
|
+
channel.connect();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export { runChatControllers };
|
|
@@ -3,7 +3,7 @@ import { HttpServerProvider } from '../http/HttpServerProvider.js';
|
|
|
3
3
|
import express from 'express';
|
|
4
4
|
import { singleton } from 'tsyringe';
|
|
5
5
|
import bodyParser from 'body-parser';
|
|
6
|
-
import { Logger } from '../../logger/Logger.js';
|
|
6
|
+
import { Logger } from '../../core/logger/Logger.js';
|
|
7
7
|
|
|
8
8
|
let ExpressProvider = class ExpressProvider {
|
|
9
9
|
httpServerProvider;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { __decorate, __metadata } from 'tslib';
|
|
2
|
-
import { injectable } from '
|
|
2
|
+
import { injectable } from '../../core/injection/index.js';
|
|
3
3
|
import { Mindset } from './IMindset.js';
|
|
4
4
|
import { MindsetMetadataStore } from './metadata/MindsetMetadataStore.js';
|
|
5
|
-
import { Container } from '
|
|
5
|
+
import { Container } from '../../core/injection/Container.js';
|
|
6
6
|
|
|
7
7
|
let MindsetOperator = class MindsetOperator {
|
|
8
8
|
mindset;
|
|
@@ -93,9 +93,6 @@ let MindsetOperator = class MindsetOperator {
|
|
|
93
93
|
description,
|
|
94
94
|
};
|
|
95
95
|
}
|
|
96
|
-
/**
|
|
97
|
-
* @deprecated use id
|
|
98
|
-
*/
|
|
99
96
|
async callFunction(name, params) {
|
|
100
97
|
const fnMetadata = this.metadata.modules
|
|
101
98
|
.map((module) => module.functions)
|
|
@@ -117,62 +114,6 @@ let MindsetOperator = class MindsetOperator {
|
|
|
117
114
|
return `Error: ${error}`;
|
|
118
115
|
}
|
|
119
116
|
}
|
|
120
|
-
/**
|
|
121
|
-
* @deprecated use id
|
|
122
|
-
*/
|
|
123
|
-
async allFunctionsDescriptors() {
|
|
124
|
-
return this.metadata.modules
|
|
125
|
-
.map((module) => module.functions.map((fn) => this.functionDescriptor(fn)))
|
|
126
|
-
.flat();
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* @deprecated use id
|
|
130
|
-
*/
|
|
131
|
-
functionDescriptor(fn) {
|
|
132
|
-
const description = fn.config.description.replaceAll('#', ' ');
|
|
133
|
-
return {
|
|
134
|
-
type: 'function',
|
|
135
|
-
name: fn.name,
|
|
136
|
-
description,
|
|
137
|
-
parameters: {
|
|
138
|
-
type: 'object',
|
|
139
|
-
properties: fn.params.reduce((prev, param) => ({
|
|
140
|
-
...prev,
|
|
141
|
-
[param.name]: this.toolParam(param),
|
|
142
|
-
}), {}),
|
|
143
|
-
required: fn.params.filter((param) => !param.config.optional).map((param) => param.name),
|
|
144
|
-
},
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* @deprecated use id
|
|
149
|
-
*/
|
|
150
|
-
toolParam(param) {
|
|
151
|
-
const addons = {
|
|
152
|
-
description: `
|
|
153
|
-
### description (in your main language)
|
|
154
|
-
${param.config.description.replaceAll('#', ' ')}
|
|
155
|
-
`,
|
|
156
|
-
};
|
|
157
|
-
const type = (() => {
|
|
158
|
-
if (param.type === Number)
|
|
159
|
-
return 'number';
|
|
160
|
-
if (param.type === String)
|
|
161
|
-
return 'string';
|
|
162
|
-
if (param.type === Date) {
|
|
163
|
-
addons.description = `${addons.description}
|
|
164
|
-
### format: ISO 8681 - YYYY-MM-DDTHH:mm:ssZ
|
|
165
|
-
${addons.description}
|
|
166
|
-
`;
|
|
167
|
-
return 'string';
|
|
168
|
-
}
|
|
169
|
-
throw new Error(`Unsupported type`);
|
|
170
|
-
})();
|
|
171
|
-
return {
|
|
172
|
-
type,
|
|
173
|
-
...addons,
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
117
|
};
|
|
177
118
|
MindsetOperator = __decorate([
|
|
178
119
|
injectable(),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __decorate } from 'tslib';
|
|
2
|
-
import { singleton } from '
|
|
2
|
+
import { singleton } from '../../../core/injection/index.js';
|
|
3
3
|
import { MINDSET_FUNCTION_DECORATION_FUNCTION } from './functions/decoratorNames.js';
|
|
4
4
|
import { MINDSET_DECORATION_MINDSET } from './mindsets/decoratorNames.js';
|
|
5
5
|
import { MINDSET_MODULE_DECORATION_MODULE } from './modules/decoratorNames.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
|
-
import { container } from '
|
|
2
|
+
import { container } from '../../../../core/injection/index.js';
|
|
3
3
|
import { MindsetMetadataStore } from '../MindsetMetadataStore.js';
|
|
4
4
|
import { MINDSET_FUNCTION_DECORATION_FUNCTION } from './decoratorNames.js';
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
|
-
import { container, injectable } from '
|
|
2
|
+
import { container, injectable } from '../../../../core/injection/index.js';
|
|
3
3
|
import { MindsetMetadataStore } from '../MindsetMetadataStore.js';
|
|
4
4
|
import { MINDSET_DECORATION_MINDSET } from './decoratorNames.js';
|
|
5
5
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import '
|
|
2
|
-
import { container, injectable } from '../../../injection/index.js';
|
|
1
|
+
import { container, injectable } from '../../../../core/injection/index.js';
|
|
3
2
|
import { MindsetMetadataStore } from '../MindsetMetadataStore.js';
|
|
4
3
|
import { MINDSET_MODULE_DECORATION_MODULE } from './decoratorNames.js';
|
|
5
4
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
import { MindsetMetadataStore } from '../MindsetMetadataStore.js';
|
|
3
|
-
import { container } from '
|
|
3
|
+
import { container } from '../../../../core/injection/index.js';
|
|
4
4
|
import { PARAM_DECORATION_PARAM } from './decoratorNames.js';
|
|
5
5
|
|
|
6
6
|
function param(config) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __decorate } from 'tslib';
|
|
2
|
-
import { CustomError } from '
|
|
3
|
-
import { scoped, Lifecycle } from '
|
|
2
|
+
import { CustomError } from '../../../core/error/CustomError.js';
|
|
3
|
+
import { scoped, Lifecycle } from '../../../core/injection/index.js';
|
|
4
4
|
|
|
5
5
|
let Auth = class Auth {
|
|
6
6
|
authInfo = null;
|
|
@@ -1,29 +1,11 @@
|
|
|
1
|
-
import '../controller/channel/ChatResolver.js';
|
|
2
|
-
import '../controller/channel/UserResolver.js';
|
|
3
|
-
import { container } from '../injection/index.js';
|
|
4
|
-
import '../controller/metadata/ControllerMetadataStore.js';
|
|
5
|
-
import '../channels/cmd/CmdChannel.js';
|
|
6
|
-
import { ExpressProvider } from '../channels/express/ExpressProvider.js';
|
|
7
|
-
import '../channels/http/HttpServerProvider.js';
|
|
8
|
-
import '../channels/socket/SocketChannel.js';
|
|
9
|
-
import '../channels/socket/SocketChannelConfig.js';
|
|
10
|
-
import '../channels/socket/SocketServerProvider.js';
|
|
11
|
-
import '../channels/telegram/TelegramChannel.js';
|
|
12
|
-
import '../channels/whatsapp/WhatsAppChannel.js';
|
|
13
|
-
import '../channels/whatsapp/EnvWhatsAppRepository.js';
|
|
14
|
-
import '../channels/whatsapp/PgWhatsAppRepository.js';
|
|
15
|
-
import '../core/chat/repository/IChatRepository.js';
|
|
16
|
-
import '../core/user/IUserRepository.js';
|
|
17
|
-
import '../channels/whatsapp/WhatsAppReceiverByDevConnection.js';
|
|
18
|
-
import '../channels/whatsapp/WhatsAppReceiverByWebHook.js';
|
|
19
|
-
import '../channels/whatsapp/WhatsAppSenderByCloudApi.js';
|
|
20
|
-
import '../channels/whatsapp/WhatsAppSenderByDevConnection.js';
|
|
21
|
-
import { Logger } from '../logger/Logger.js';
|
|
22
|
-
import '../validation/metadata/ValidationMetadataStore.js';
|
|
23
|
-
import { validate } from '../validation/validate.js';
|
|
24
1
|
import path from 'path';
|
|
2
|
+
import { container } from '../../core/injection/index.js';
|
|
25
3
|
import { RestControllerMetadataStore } from './metadata/RestControllerMetadataStore.js';
|
|
26
|
-
import {
|
|
4
|
+
import { Logger } from '../../core/logger/Logger.js';
|
|
5
|
+
import { ExpressProvider } from '../express/ExpressProvider.js';
|
|
6
|
+
import '../../core/validation/metadata/ValidationMetadataStore.js';
|
|
7
|
+
import { validate } from '../../core/validation/validate.js';
|
|
8
|
+
import { CustomError } from '../../core/error/CustomError.js';
|
|
27
9
|
|
|
28
10
|
function buildRequest(req) {
|
|
29
11
|
return Object.assign({}, req.body, req.query, req.params);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __decorate, __metadata } from 'tslib';
|
|
2
|
-
import { Logger } from '../../logger/Logger.js';
|
|
2
|
+
import { Logger } from '../../core/logger/Logger.js';
|
|
3
3
|
import { HttpServerProvider } from '../http/HttpServerProvider.js';
|
|
4
4
|
import { Server } from 'socket.io';
|
|
5
5
|
import { singleton } from 'tsyringe';
|