@wabot-dev/framework 0.1.0-beta.4 → 0.1.0-beta.40
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/anthropic/AnthropicChatAdapter.js +128 -0
- package/dist/src/addon/chat-bot/deepseek/DeepSeekChatAdapter.js +137 -0
- package/dist/src/addon/chat-bot/google/GoogleChatAdapter.js +120 -0
- package/dist/src/addon/chat-bot/openia/OpenaiChatAdapter.js +111 -0
- 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 +2 -2
- package/dist/src/addon/chat-controller/cmd/@cmd.js +22 -0
- package/dist/src/{channels → addon/chat-controller}/cmd/CmdChannel.js +4 -26
- package/dist/src/{channels → addon/chat-controller}/socket/@socket.js +8 -4
- package/dist/src/{channels → addon/chat-controller}/socket/SocketChannel.js +5 -23
- 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 +4 -22
- package/dist/src/{channels → addon/chat-controller}/whatsapp/@whatsapp.js +8 -4
- package/dist/src/{channels → addon/chat-controller}/whatsapp/EnvWhatsAppRepository.js +3 -3
- 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 +2 -4
- package/dist/src/{channels → addon/chat-controller}/whatsapp/WhatsAppChannel.js +6 -18
- package/dist/src/{channels → addon/chat-controller}/whatsapp/WhatsAppReceiver.js +4 -7
- package/dist/src/{channels → addon/chat-controller}/whatsapp/WhatsAppReceiverByDevConnection.js +4 -10
- package/dist/src/{channels → addon/chat-controller}/whatsapp/WhatsAppReceiverByWebHook.js +6 -12
- package/dist/src/{channels → addon/chat-controller}/whatsapp/WhatsAppSender.js +39 -10
- package/dist/src/{channels → addon/chat-controller}/whatsapp/WhatsAppSenderByCloudApi.js +10 -13
- package/dist/src/{channels → addon/chat-controller}/whatsapp/WhatsAppSenderByDevConnection.js +13 -15
- package/dist/src/addon/mindset/html/HtmlModule.js +70 -0
- package/dist/src/addon/money/MoneyDto.js +22 -0
- package/dist/src/{repository → addon/repository}/pg/PgCrudRepository.js +23 -2
- package/dist/src/{repository → addon/repository}/pg/PgRepositoryBase.js +2 -2
- package/dist/src/addon/rest-controller/jwt/@jwtGuard.js +17 -0
- package/dist/src/addon/rest-controller/jwt/Jwt.js +31 -0
- package/dist/src/addon/rest-controller/jwt/JwtAccessAndRefreshTokenDto.js +20 -0
- package/dist/src/addon/rest-controller/jwt/JwtConfig.js +28 -0
- package/dist/src/addon/rest-controller/jwt/JwtGuardMiddleware.js +45 -0
- package/dist/src/addon/rest-controller/jwt/JwtRefreshToken.js +9 -0
- package/dist/src/addon/rest-controller/jwt/JwtRefreshTokenRepository.js +21 -0
- package/dist/src/addon/rest-controller/jwt/JwtSigner.js +48 -0
- package/dist/src/addon/rest-controller/jwt/JwtTokenDto.js +22 -0
- package/dist/src/addon/validation/is-boolean/@isBoolean.js +17 -0
- package/dist/src/addon/validation/is-boolean/validateIsBoolean.js +12 -0
- package/dist/src/addon/validation/is-date/@isDate.js +17 -0
- package/dist/src/addon/validation/is-date/validateIsDate.js +16 -0
- package/dist/src/addon/validation/is-not-empty/@isNotEmpty.js +17 -0
- package/dist/src/addon/validation/is-not-empty/validateIsNotEmpty.js +12 -0
- package/dist/src/addon/validation/is-number/@isNumber.js +17 -0
- package/dist/src/addon/validation/is-number/validateIsNumber.js +12 -0
- package/dist/src/addon/validation/is-present/@isPresent.js +17 -0
- package/dist/src/addon/validation/is-present/validateIsPresent.js +12 -0
- package/dist/src/addon/validation/is-string/@isString.js +17 -0
- package/dist/src/addon/validation/is-string/validateIsString.js +12 -0
- package/dist/src/addon/validation/max/@max.js +18 -0
- package/dist/src/addon/validation/max/validateMax.js +17 -0
- package/dist/src/addon/validation/min/@min.js +18 -0
- package/dist/src/addon/validation/min/validateMin.js +17 -0
- package/dist/src/core/auth/Auth.js +24 -0
- package/dist/src/core/{Persistent.js → entity/Entity.js} +24 -9
- package/dist/src/core/env/Env.js +39 -0
- package/dist/src/core/error/CustomError.js +15 -0
- package/dist/src/core/injection/index.js +4 -0
- package/dist/src/core/mapper/Mapper.js +42 -0
- package/dist/src/core/random/Random.js +37 -0
- package/dist/src/core/storable/Storable.js +8 -0
- package/dist/src/core/validation/metadata/@isArray.js +18 -0
- package/dist/src/core/validation/metadata/@isModel.js +18 -0
- package/dist/src/core/validation/metadata/@isOptional.js +17 -0
- package/dist/src/core/validation/metadata/ValidationMetadataStore.js +98 -0
- package/dist/src/core/validation/modelInfo.js +9 -0
- package/dist/src/core/validation/validate.js +11 -0
- package/dist/src/core/validation/validators/validateArray.js +51 -0
- package/dist/src/core/validation/validators/validateIsOptional.js +5 -0
- package/dist/src/core/validation/validators/validateModel.js +36 -0
- package/dist/src/feature/async/@command.js +11 -0
- package/dist/src/feature/async/@commandHandler.js +12 -0
- package/dist/src/feature/async/Async.js +38 -0
- package/dist/src/feature/async/Command.js +9 -0
- package/dist/src/feature/async/CommandMetadataStore.js +38 -0
- package/dist/src/feature/async/Job.js +24 -0
- package/dist/src/feature/async/JobRepository.js +31 -0
- package/dist/src/feature/async/JobRunner.js +45 -0
- package/dist/src/feature/async/JobsEventsHub.js +24 -0
- package/dist/src/feature/async/runCommandHandlers.js +29 -0
- package/dist/src/{core/chat → feature/chat-bot}/Chat.js +2 -2
- 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 +2 -4
- package/dist/src/{channels → feature}/http/HttpServerProvider.js +2 -2
- package/dist/src/{mindset → feature/mindset}/MindsetOperator.js +66 -42
- 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/feature/money/Money.js +61 -0
- package/dist/src/feature/rest-controller/injection-tokens.js +4 -0
- package/dist/src/feature/rest-controller/metadata/@get.js +19 -0
- package/dist/src/feature/rest-controller/metadata/@middleware.js +16 -0
- package/dist/src/feature/rest-controller/metadata/@post.js +19 -0
- package/dist/src/feature/rest-controller/metadata/@restController.js +15 -0
- package/dist/src/feature/rest-controller/metadata/RestControllerMetadataStore.js +50 -0
- package/dist/src/feature/rest-controller/runRestControllers.js +88 -0
- package/dist/src/{channels → feature}/socket/SocketServerProvider.js +2 -2
- package/dist/src/index.d.ts +848 -483
- package/dist/src/index.js +122 -76
- package/package.json +9 -3
- package/dist/src/ai/deepseek/DeepSeekChatBotAdapter.js +0 -106
- package/dist/src/ai/openia/OpenaiChatBotAdapter.js +0 -84
- package/dist/src/channels/cmd/@cmd.js +0 -18
- package/dist/src/chatbot/ChatBot.js +0 -51
- package/dist/src/chatbot/ChatBotAdapter.js +0 -72
- 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/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/env/WabotEnv.js +0 -27
- package/dist/src/injection/index.js +0 -4
- package/dist/src/mindset/metadata/params/@isOptional.js +0 -21
- 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/{injection → core/injection}/Container.js +0 -0
- /package/dist/src/{logger → core/logger}/Logger.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
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { __decorate } from 'tslib';
|
|
2
|
-
import { singleton } from '../../injection/index.js';
|
|
3
|
-
|
|
4
|
-
let UserRepository = class UserRepository {
|
|
5
|
-
create(chat) {
|
|
6
|
-
throw new Error('Method not implemented.');
|
|
7
|
-
}
|
|
8
|
-
update(chat) {
|
|
9
|
-
throw new Error('Method not implemented.');
|
|
10
|
-
}
|
|
11
|
-
findByConnection(query) {
|
|
12
|
-
throw new Error('Method not implemented.');
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
UserRepository = __decorate([
|
|
16
|
-
singleton()
|
|
17
|
-
], UserRepository);
|
|
18
|
-
|
|
19
|
-
export { UserRepository };
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { Persistent } from '../Persistent.js';
|
|
2
|
-
|
|
3
|
-
class User extends Persistent {
|
|
4
|
-
constructor(data) {
|
|
5
|
-
super(data);
|
|
6
|
-
}
|
|
7
|
-
hasConnection(connection) {
|
|
8
|
-
for (const con of this.data.connections) {
|
|
9
|
-
if (con.channelName === connection.channelName && con.id === connection.id) {
|
|
10
|
-
return true;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
getValue(key) {
|
|
16
|
-
return this.data.keyValueData[key];
|
|
17
|
-
}
|
|
18
|
-
setValue(key, value) {
|
|
19
|
-
this.data.keyValueData[key] = value;
|
|
20
|
-
}
|
|
21
|
-
addConnection(connection) {
|
|
22
|
-
this.data.connections.push(connection);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export { User };
|
package/dist/src/env/WabotEnv.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { __decorate, __metadata } from 'tslib';
|
|
2
|
-
import { singleton } from 'tsyringe';
|
|
3
|
-
|
|
4
|
-
let WabotEnv = class WabotEnv {
|
|
5
|
-
envType;
|
|
6
|
-
constructor() {
|
|
7
|
-
this.envType = process.env.WABOT_ENV ?? 'development';
|
|
8
|
-
}
|
|
9
|
-
isDevelopment() {
|
|
10
|
-
return this.envType === 'development';
|
|
11
|
-
}
|
|
12
|
-
isProduction() {
|
|
13
|
-
return this.envType === 'production';
|
|
14
|
-
}
|
|
15
|
-
requireString(varName) {
|
|
16
|
-
const value = process.env[varName];
|
|
17
|
-
if (!value)
|
|
18
|
-
throw new Error(`Env Variable ${varName} is required`);
|
|
19
|
-
return value;
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
WabotEnv = __decorate([
|
|
23
|
-
singleton(),
|
|
24
|
-
__metadata("design:paramtypes", [])
|
|
25
|
-
], WabotEnv);
|
|
26
|
-
|
|
27
|
-
export { WabotEnv };
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import 'reflect-metadata';
|
|
2
|
-
import { MindsetMetadataStore } from '../MindsetMetadataStore.js';
|
|
3
|
-
import { container } from '../../../injection/index.js';
|
|
4
|
-
import { PARAM_DECORATION_IS_OPTIONAL } from './decoratorNames.js';
|
|
5
|
-
|
|
6
|
-
function isOptional() {
|
|
7
|
-
return (target, propertyKey) => {
|
|
8
|
-
const paramName = propertyKey.toString();
|
|
9
|
-
const paramType = Reflect.getMetadata('design:type', target, paramName);
|
|
10
|
-
const store = container.resolve(MindsetMetadataStore);
|
|
11
|
-
store.saveParamDecoration({
|
|
12
|
-
decorationName: PARAM_DECORATION_IS_OPTIONAL,
|
|
13
|
-
paramType: paramType,
|
|
14
|
-
paramName: paramName,
|
|
15
|
-
constructor: target.constructor,
|
|
16
|
-
decorationConfig: {},
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export { isOptional };
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { __decorate, __metadata } from 'tslib';
|
|
2
|
-
import '../../../core/chat/repository/IChatRepository.js';
|
|
3
|
-
import { UserRepository } from '../../../core/user/IUserRepository.js';
|
|
4
|
-
import { MessageContext } from '../../../core/IMessageContext.js';
|
|
5
|
-
import { mindsetFunction } from '../../../mindset/metadata/functions/@mindsetFunction.js';
|
|
6
|
-
import 'reflect-metadata';
|
|
7
|
-
import '../../../injection/index.js';
|
|
8
|
-
import '../../../mindset/metadata/MindsetMetadataStore.js';
|
|
9
|
-
import { mindsetModule } from '../../../mindset/metadata/modules/@mindsetModule.js';
|
|
10
|
-
import '../../../mindset/MindsetOperator.js';
|
|
11
|
-
import { EmailService } from '../../service/EmailService.js';
|
|
12
|
-
import { OtpService } from '../../service/OtpService.js';
|
|
13
|
-
import { SendOneTimePasswordRequest } from './requests/SendOneTimePasswordRequest.js';
|
|
14
|
-
import { ValidateOneTimePasswordRequest } from './requests/ValidateOneTimePasswordRequest.js';
|
|
15
|
-
|
|
16
|
-
let AuthenticationModule = class AuthenticationModule {
|
|
17
|
-
userRepository;
|
|
18
|
-
emailService;
|
|
19
|
-
otpService;
|
|
20
|
-
context;
|
|
21
|
-
constructor(userRepository, emailService, otpService, context) {
|
|
22
|
-
this.userRepository = userRepository;
|
|
23
|
-
this.emailService = emailService;
|
|
24
|
-
this.otpService = otpService;
|
|
25
|
-
this.context = context;
|
|
26
|
-
}
|
|
27
|
-
async sendOneTimePassword(request) {
|
|
28
|
-
const user = await this.userRepository.findByConnection({
|
|
29
|
-
channelName: 'EmailChannel',
|
|
30
|
-
id: request.toEmail,
|
|
31
|
-
});
|
|
32
|
-
if (!user)
|
|
33
|
-
return 'success';
|
|
34
|
-
const otp = await this.otpService.generate();
|
|
35
|
-
const html = await this.generateOtpEmailHtml(otp, user);
|
|
36
|
-
const subject = await this.generateOtpEmailSubject();
|
|
37
|
-
await this.emailService.sendEmail({
|
|
38
|
-
from: request.fromEmail,
|
|
39
|
-
to: request.toEmail,
|
|
40
|
-
subject,
|
|
41
|
-
html,
|
|
42
|
-
});
|
|
43
|
-
user.setValue('OTP', otp);
|
|
44
|
-
await this.userRepository.update(user);
|
|
45
|
-
return 'success';
|
|
46
|
-
}
|
|
47
|
-
async validateOneTimePassword(request) {
|
|
48
|
-
const user = await this.userRepository.findByConnection({
|
|
49
|
-
channelName: 'EmailChannel',
|
|
50
|
-
id: request.userEmail,
|
|
51
|
-
});
|
|
52
|
-
if (!user) {
|
|
53
|
-
throw new Error('Invalid OTP');
|
|
54
|
-
}
|
|
55
|
-
const otp = user.getValue('OTP');
|
|
56
|
-
if (otp !== request.otp) {
|
|
57
|
-
throw new Error('Invalid OTP');
|
|
58
|
-
}
|
|
59
|
-
user.addConnection(this.context.message.userConnection);
|
|
60
|
-
await this.userRepository.update(user);
|
|
61
|
-
return 'success';
|
|
62
|
-
}
|
|
63
|
-
async generateOtpEmailHtml(otp, user) {
|
|
64
|
-
return `<p>Your OTP Code is ${otp}</p>`;
|
|
65
|
-
}
|
|
66
|
-
async generateOtpEmailSubject() {
|
|
67
|
-
return 'OTP Code';
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
__decorate([
|
|
71
|
-
mindsetFunction({
|
|
72
|
-
description: 'Send an One Time Password to the user when want authenticate',
|
|
73
|
-
}),
|
|
74
|
-
__metadata("design:type", Function),
|
|
75
|
-
__metadata("design:paramtypes", [SendOneTimePasswordRequest]),
|
|
76
|
-
__metadata("design:returntype", Promise)
|
|
77
|
-
], AuthenticationModule.prototype, "sendOneTimePassword", null);
|
|
78
|
-
__decorate([
|
|
79
|
-
mindsetFunction({
|
|
80
|
-
description: 'Send an One Time Password to the user when want authenticate',
|
|
81
|
-
}),
|
|
82
|
-
__metadata("design:type", Function),
|
|
83
|
-
__metadata("design:paramtypes", [ValidateOneTimePasswordRequest]),
|
|
84
|
-
__metadata("design:returntype", Promise)
|
|
85
|
-
], AuthenticationModule.prototype, "validateOneTimePassword", null);
|
|
86
|
-
AuthenticationModule = __decorate([
|
|
87
|
-
mindsetModule({
|
|
88
|
-
description: 'Provide authentication methods',
|
|
89
|
-
language: 'english',
|
|
90
|
-
}),
|
|
91
|
-
__metadata("design:paramtypes", [UserRepository,
|
|
92
|
-
EmailService,
|
|
93
|
-
OtpService,
|
|
94
|
-
MessageContext])
|
|
95
|
-
], AuthenticationModule);
|
|
96
|
-
|
|
97
|
-
export { AuthenticationModule };
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { __decorate, __metadata } from 'tslib';
|
|
2
|
-
import 'reflect-metadata';
|
|
3
|
-
import '../../../../injection/index.js';
|
|
4
|
-
import '../../../../mindset/metadata/MindsetMetadataStore.js';
|
|
5
|
-
import { param } from '../../../../mindset/metadata/params/@param.js';
|
|
6
|
-
import '../../../../mindset/MindsetOperator.js';
|
|
7
|
-
|
|
8
|
-
class SendOneTimePasswordRequest {
|
|
9
|
-
fromEmail = '';
|
|
10
|
-
toEmail = '';
|
|
11
|
-
}
|
|
12
|
-
__decorate([
|
|
13
|
-
param({
|
|
14
|
-
description: 'Sender Email address',
|
|
15
|
-
}),
|
|
16
|
-
__metadata("design:type", String)
|
|
17
|
-
], SendOneTimePasswordRequest.prototype, "fromEmail", void 0);
|
|
18
|
-
__decorate([
|
|
19
|
-
param({
|
|
20
|
-
description: 'Recipient Email Address, to send one time password',
|
|
21
|
-
}),
|
|
22
|
-
__metadata("design:type", String)
|
|
23
|
-
], SendOneTimePasswordRequest.prototype, "toEmail", void 0);
|
|
24
|
-
|
|
25
|
-
export { SendOneTimePasswordRequest };
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { __decorate, __metadata } from 'tslib';
|
|
2
|
-
import 'reflect-metadata';
|
|
3
|
-
import '../../../../injection/index.js';
|
|
4
|
-
import '../../../../mindset/metadata/MindsetMetadataStore.js';
|
|
5
|
-
import { param } from '../../../../mindset/metadata/params/@param.js';
|
|
6
|
-
import '../../../../mindset/MindsetOperator.js';
|
|
7
|
-
|
|
8
|
-
class ValidateOneTimePasswordRequest {
|
|
9
|
-
userEmail = '';
|
|
10
|
-
otp = '';
|
|
11
|
-
}
|
|
12
|
-
__decorate([
|
|
13
|
-
param({
|
|
14
|
-
description: 'User Email',
|
|
15
|
-
}),
|
|
16
|
-
__metadata("design:type", String)
|
|
17
|
-
], ValidateOneTimePasswordRequest.prototype, "userEmail", void 0);
|
|
18
|
-
__decorate([
|
|
19
|
-
param({
|
|
20
|
-
description: 'Otp provided by the User',
|
|
21
|
-
}),
|
|
22
|
-
__metadata("design:type", String)
|
|
23
|
-
], ValidateOneTimePasswordRequest.prototype, "otp", void 0);
|
|
24
|
-
|
|
25
|
-
export { ValidateOneTimePasswordRequest };
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { __decorate, __metadata } from 'tslib';
|
|
2
|
-
import '../../../core/chat/repository/IChatRepository.js';
|
|
3
|
-
import { User } from '../../../core/user/User.js';
|
|
4
|
-
import { UserRepository } from '../../../core/user/IUserRepository.js';
|
|
5
|
-
import { MessageContext } from '../../../core/IMessageContext.js';
|
|
6
|
-
import { mindsetFunction } from '../../../mindset/metadata/functions/@mindsetFunction.js';
|
|
7
|
-
import 'reflect-metadata';
|
|
8
|
-
import '../../../injection/index.js';
|
|
9
|
-
import '../../../mindset/metadata/MindsetMetadataStore.js';
|
|
10
|
-
import { mindsetModule } from '../../../mindset/metadata/modules/@mindsetModule.js';
|
|
11
|
-
import '../../../mindset/MindsetOperator.js';
|
|
12
|
-
import { RegisterUserWithEmailRequest } from './requests/RegisterUserWithEmailRequest.js';
|
|
13
|
-
|
|
14
|
-
let RegisterUserModule = class RegisterUserModule {
|
|
15
|
-
userRepository;
|
|
16
|
-
context;
|
|
17
|
-
constructor(userRepository, context) {
|
|
18
|
-
this.userRepository = userRepository;
|
|
19
|
-
this.context = context;
|
|
20
|
-
}
|
|
21
|
-
async registerUserWithEmail(request) {
|
|
22
|
-
if (this.context.user) {
|
|
23
|
-
throw new Error('The User is already authenticated');
|
|
24
|
-
}
|
|
25
|
-
const user = new User({
|
|
26
|
-
shortName: request.shortName,
|
|
27
|
-
connections: [
|
|
28
|
-
{
|
|
29
|
-
channelName: 'EmailChannel',
|
|
30
|
-
id: request.email,
|
|
31
|
-
},
|
|
32
|
-
],
|
|
33
|
-
keyValueData: {},
|
|
34
|
-
});
|
|
35
|
-
await this.userRepository.create(user);
|
|
36
|
-
return 'success';
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
__decorate([
|
|
40
|
-
mindsetFunction({
|
|
41
|
-
description: 'Register a new user using email',
|
|
42
|
-
}),
|
|
43
|
-
__metadata("design:type", Function),
|
|
44
|
-
__metadata("design:paramtypes", [RegisterUserWithEmailRequest]),
|
|
45
|
-
__metadata("design:returntype", Promise)
|
|
46
|
-
], RegisterUserModule.prototype, "registerUserWithEmail", null);
|
|
47
|
-
RegisterUserModule = __decorate([
|
|
48
|
-
mindsetModule({
|
|
49
|
-
description: 'Provide functions to register an user',
|
|
50
|
-
language: 'english',
|
|
51
|
-
}),
|
|
52
|
-
__metadata("design:paramtypes", [UserRepository,
|
|
53
|
-
MessageContext])
|
|
54
|
-
], RegisterUserModule);
|
|
55
|
-
|
|
56
|
-
export { RegisterUserModule };
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { __decorate, __metadata } from 'tslib';
|
|
2
|
-
import 'reflect-metadata';
|
|
3
|
-
import '../../../../injection/index.js';
|
|
4
|
-
import '../../../../mindset/metadata/MindsetMetadataStore.js';
|
|
5
|
-
import { param } from '../../../../mindset/metadata/params/@param.js';
|
|
6
|
-
import '../../../../mindset/MindsetOperator.js';
|
|
7
|
-
|
|
8
|
-
class RegisterUserWithEmailRequest {
|
|
9
|
-
email = '';
|
|
10
|
-
shortName = '';
|
|
11
|
-
}
|
|
12
|
-
__decorate([
|
|
13
|
-
param({
|
|
14
|
-
description: 'Email of the User',
|
|
15
|
-
}),
|
|
16
|
-
__metadata("design:type", String)
|
|
17
|
-
], RegisterUserWithEmailRequest.prototype, "email", void 0);
|
|
18
|
-
__decorate([
|
|
19
|
-
param({
|
|
20
|
-
description: 'ShortName for the new User',
|
|
21
|
-
}),
|
|
22
|
-
__metadata("design:type", String)
|
|
23
|
-
], RegisterUserWithEmailRequest.prototype, "shortName", void 0);
|
|
24
|
-
|
|
25
|
-
export { RegisterUserWithEmailRequest };
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { __decorate, __metadata } from 'tslib';
|
|
2
|
-
import '../../../../core/chat/repository/IChatRepository.js';
|
|
3
|
-
import { User } from '../../../../core/user/User.js';
|
|
4
|
-
import '../../../../core/user/IUserRepository.js';
|
|
5
|
-
import { singleton } from '../../../../injection/index.js';
|
|
6
|
-
import { PgCrudRepository } from '../../../../repository/pg/PgCrudRepository.js';
|
|
7
|
-
import { Pool } from 'pg';
|
|
8
|
-
|
|
9
|
-
let PgUserRepository = class PgUserRepository extends PgCrudRepository {
|
|
10
|
-
constructor(pool) {
|
|
11
|
-
super(pool, {
|
|
12
|
-
table: 'user',
|
|
13
|
-
schema: 'wabot',
|
|
14
|
-
constructor: User,
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
async findByConnection(query) {
|
|
18
|
-
const sql = `
|
|
19
|
-
SELECT ${this.columns}
|
|
20
|
-
FROM ${this.table}
|
|
21
|
-
WHERE data->'connections' @> $1::jsonb
|
|
22
|
-
LIMIT 1
|
|
23
|
-
`;
|
|
24
|
-
const items = await this.query(sql, [JSON.stringify([query])]);
|
|
25
|
-
return items.at(0) ?? null;
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
PgUserRepository = __decorate([
|
|
29
|
-
singleton(),
|
|
30
|
-
__metadata("design:paramtypes", [Pool])
|
|
31
|
-
], PgUserRepository);
|
|
32
|
-
|
|
33
|
-
export { PgUserRepository };
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { __decorate } from 'tslib';
|
|
2
|
-
import { v4 } from 'uuid';
|
|
3
|
-
import { singleton } from '../../../../injection/index.js';
|
|
4
|
-
|
|
5
|
-
let RamUserRepository = class RamUserRepository {
|
|
6
|
-
items = [];
|
|
7
|
-
async create(chat) {
|
|
8
|
-
if (chat.wasCreated()) {
|
|
9
|
-
throw new Error('User already created');
|
|
10
|
-
}
|
|
11
|
-
chat['data'].id = v4();
|
|
12
|
-
chat['data'].createdAt = new Date().getTime();
|
|
13
|
-
chat.validate();
|
|
14
|
-
this.items.push(chat);
|
|
15
|
-
}
|
|
16
|
-
async findByConnection(query) {
|
|
17
|
-
return this.items.find((item) => item.hasConnection(query)) ?? null;
|
|
18
|
-
}
|
|
19
|
-
async update(chat) {
|
|
20
|
-
// TODO
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
RamUserRepository = __decorate([
|
|
24
|
-
singleton()
|
|
25
|
-
], RamUserRepository);
|
|
26
|
-
|
|
27
|
-
export { RamUserRepository };
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { __decorate } from 'tslib';
|
|
2
|
-
import { injectable } from '../../injection/index.js';
|
|
3
|
-
|
|
4
|
-
let EmailService = class EmailService {
|
|
5
|
-
async sendEmail(request) {
|
|
6
|
-
throw new Error('Not implemented');
|
|
7
|
-
}
|
|
8
|
-
};
|
|
9
|
-
EmailService = __decorate([
|
|
10
|
-
injectable()
|
|
11
|
-
], EmailService);
|
|
12
|
-
|
|
13
|
-
export { EmailService };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { __decorate } from 'tslib';
|
|
2
|
-
import { injectable } from '../../injection/index.js';
|
|
3
|
-
import { randomInt } from 'crypto';
|
|
4
|
-
|
|
5
|
-
let OtpService = class OtpService {
|
|
6
|
-
async generate() {
|
|
7
|
-
return randomInt(100000, 999999).toString();
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
OtpService = __decorate([
|
|
11
|
-
injectable()
|
|
12
|
-
], OtpService);
|
|
13
|
-
|
|
14
|
-
export { OtpService };
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import '../injection/index.js';
|
|
2
|
-
import 'reflect-metadata';
|
|
3
|
-
import '../mindset/metadata/MindsetMetadataStore.js';
|
|
4
|
-
import { Mindset } from '../mindset/IMindset.js';
|
|
5
|
-
import '../mindset/MindsetOperator.js';
|
|
6
|
-
import { ChatMemory } from '../core/chat/repository/IChatMemory.js';
|
|
7
|
-
import { ChatRepository } from '../core/chat/repository/IChatRepository.js';
|
|
8
|
-
import '../core/user/IUserRepository.js';
|
|
9
|
-
import { MessageContext } from '../core/IMessageContext.js';
|
|
10
|
-
import 'uuid';
|
|
11
|
-
import { ChatBotMetadataStore } from '../chatbot/metadata/ChatBotMetadataStore.js';
|
|
12
|
-
import { ChatBot } from '../chatbot/ChatBot.js';
|
|
13
|
-
import { Container } from '../injection/Container.js';
|
|
14
|
-
|
|
15
|
-
async function prepareChatContainer(container, context, mindsetCtor) {
|
|
16
|
-
const chatContainer = container.createChildContainer();
|
|
17
|
-
chatContainer.register(Container, { useValue: chatContainer });
|
|
18
|
-
chatContainer.register(MessageContext, {
|
|
19
|
-
useValue: new MessageContext(context.message, context.chat, context.user),
|
|
20
|
-
});
|
|
21
|
-
const chatRepository = container.resolve(ChatRepository);
|
|
22
|
-
const chatMemory = await chatRepository.findMemory(context.chat.getId());
|
|
23
|
-
if (!chatMemory) {
|
|
24
|
-
throw new Error('Not found Chat Memory for Chat with Id=' + context.chat.getId());
|
|
25
|
-
}
|
|
26
|
-
chatContainer.register(ChatMemory, { useValue: chatMemory });
|
|
27
|
-
const chatBotMetadataStore = container.resolve(ChatBotMetadataStore);
|
|
28
|
-
const chatBots = chatBotMetadataStore.getChatBotsMetadata();
|
|
29
|
-
for (const chatBotMetadata of chatBots) {
|
|
30
|
-
chatContainer.beforeResolution(chatBotMetadata.constructor, (a, b) => {
|
|
31
|
-
const subContainer = chatContainer.createChildContainer();
|
|
32
|
-
subContainer.register(Mindset, { useClass: chatBotMetadata.mindsetConstructor });
|
|
33
|
-
const chatBot = subContainer.resolve(ChatBot);
|
|
34
|
-
chatContainer.register(chatBotMetadata.injectionToken, { useValue: chatBot });
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
if (mindsetCtor) {
|
|
38
|
-
chatContainer.register(Mindset, { useClass: mindsetCtor });
|
|
39
|
-
}
|
|
40
|
-
return chatContainer;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export { prepareChatContainer };
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { container } from '../injection/index.js';
|
|
2
|
-
import 'uuid';
|
|
3
|
-
import '../chatbot/metadata/ChatBotMetadataStore.js';
|
|
4
|
-
import { ChatBot } from '../chatbot/ChatBot.js';
|
|
5
|
-
import { ChatBotAdapter } from '../chatbot/ChatBotAdapter.js';
|
|
6
|
-
import { ChatRepository } from '../core/chat/repository/IChatRepository.js';
|
|
7
|
-
import '../core/user/IUserRepository.js';
|
|
8
|
-
import { prepareChatContainer } from './prepareChatContainer.js';
|
|
9
|
-
|
|
10
|
-
function runChannel(props) {
|
|
11
|
-
container.registerSingleton(ChatRepository, props.chatRepository);
|
|
12
|
-
container.register(ChatBotAdapter, { useClass: props.chatBotAdapter });
|
|
13
|
-
if (props.channelConfig) {
|
|
14
|
-
container.register(props.channelConfig.constructor, { useValue: props.channelConfig });
|
|
15
|
-
}
|
|
16
|
-
const channel = container.resolve(props.channel);
|
|
17
|
-
channel.listen(async (context) => {
|
|
18
|
-
const channelContainer = await prepareChatContainer(container, context, props.mindset);
|
|
19
|
-
const chatBot = channelContainer.resolve(ChatBot);
|
|
20
|
-
chatBot.sendMessage(context.message, (replyMessage) => {
|
|
21
|
-
context.reply(replyMessage);
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
channel.connect();
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export { runChannel };
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import '../controller/channel/ChatResolver.js';
|
|
2
|
-
import '../controller/channel/UserResolver.js';
|
|
3
|
-
import { container } from '../injection/index.js';
|
|
4
|
-
import { ControllerMetadataStore } from '../controller/metadata/ControllerMetadataStore.js';
|
|
5
|
-
import { prepareChatContainer } from './prepareChatContainer.js';
|
|
6
|
-
|
|
7
|
-
function runServer(config) {
|
|
8
|
-
for (const provider of config.providers ?? []) {
|
|
9
|
-
if (provider.singleton) {
|
|
10
|
-
container.registerSingleton(provider.replace, provider.with);
|
|
11
|
-
}
|
|
12
|
-
else {
|
|
13
|
-
container.register(provider.replace, provider.with);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
const metadataStore = container.resolve(ControllerMetadataStore);
|
|
17
|
-
for (const controllerCtor of config.controllers) {
|
|
18
|
-
const chatControllerMetadata = metadataStore.getChatControllerMetadata(controllerCtor);
|
|
19
|
-
if (!chatControllerMetadata) {
|
|
20
|
-
continue;
|
|
21
|
-
}
|
|
22
|
-
for (const channelMetadata of chatControllerMetadata.channels) {
|
|
23
|
-
const channelContainer = container.createChildContainer();
|
|
24
|
-
if (channelMetadata.channelConfig) {
|
|
25
|
-
channelContainer.register(channelMetadata.channelConfig.constructor, {
|
|
26
|
-
useValue: channelMetadata.channelConfig,
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
const channel = channelContainer.resolve(channelMetadata.channelConstructor);
|
|
30
|
-
channel.listen(async (messageContext) => {
|
|
31
|
-
const chatContainer = await prepareChatContainer(channelContainer, messageContext);
|
|
32
|
-
const chatController = chatContainer.resolve(channelMetadata.controllerConstructor);
|
|
33
|
-
chatController[channelMetadata.functionName](messageContext);
|
|
34
|
-
});
|
|
35
|
-
channel.connect();
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export { runServer };
|
|
File without changes
|
|
File without changes
|
/package/dist/src/{channels/wabot → addon/chat-controller/whatsapp}/WabotDevSocketContracts.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|