@wabot-dev/framework 0.1.0-beta.44 → 0.1.0-beta.46
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 +1 -1
- package/dist/src/addon/auth/api-key/@apiKeyGuard.js +17 -0
- package/dist/src/addon/auth/api-key/ApiKey.js +46 -0
- package/dist/src/addon/auth/api-key/ApiKeyGuardMiddleware.js +45 -0
- package/dist/src/addon/auth/api-key/ApiKeyRepository.js +13 -0
- package/dist/src/addon/auth/api-key/PgApiKeyRepository.js +14 -0
- package/dist/src/addon/auth/jwt/@jwtConnectionGuard.js +16 -0
- package/dist/src/addon/auth/jwt/JwtConnectionGuardMiddleware.js +57 -0
- package/dist/src/addon/auth/jwt/JwtRefreshTokenRepository.js +25 -0
- package/dist/src/addon/{rest-controller → auth}/jwt/JwtTokenDto.js +3 -3
- package/dist/src/addon/{rest-controller/jwt/JwtRefreshTokenRepository.js → auth/jwt/PgJwtRefreshTokenRepository.js} +6 -6
- package/dist/src/addon/chat-bot/openia/OpenaiChatAdapter.js +1 -1
- package/dist/src/addon/chat-bot/pg/PgChatMemory.js +1 -1
- package/dist/src/addon/chat-bot/pg/PgChatRepository.js +1 -1
- package/dist/src/addon/chat-controller/whatsapp/{@whatsapp.js → @whatsApp.js} +3 -3
- package/dist/src/addon/chat-controller/whatsapp/PgWhatsAppRepository.js +1 -1
- package/dist/src/addon/chat-controller/whatsapp/WhatsAppReceiver.js +3 -49
- package/dist/src/addon/chat-controller/whatsapp/WhatsAppSender.js +7 -44
- package/dist/src/addon/chat-controller/whatsapp/cloud-api/WhatsAppReceiverByCloudApi.js +97 -0
- package/dist/src/addon/chat-controller/whatsapp/{WhatsAppSenderByCloudApi.js → cloud-api/WhatsAppSenderByCloudApi.js} +24 -16
- package/dist/src/addon/chat-controller/whatsapp/proxy/WhatsAppProxyContracts.js +5 -0
- package/dist/src/addon/chat-controller/whatsapp/proxy/WhatsAppReceiverByWabotProxy.js +65 -0
- package/dist/src/addon/chat-controller/whatsapp/proxy/WhatsAppSenderByWabotProxy.js +60 -0
- package/dist/src/addon/chat-controller/whatsapp/proxy/WhatsAppWabotProxyConnection.js +45 -0
- package/dist/src/core/password/Password.js +30 -0
- package/dist/src/core/validation/metadata/@isArray.js +1 -1
- package/dist/src/core/validation/metadata/@isModel.js +1 -1
- package/dist/src/core/validation/metadata/@isOptional.js +1 -1
- package/dist/src/core/validation/metadata/ValidationMetadataStore.js +2 -2
- package/dist/src/core/validation/validate.js +1 -1
- package/dist/src/{addon/validation → core/validation/validators}/is-boolean/@isBoolean.js +2 -2
- package/dist/src/{addon/validation → core/validation/validators}/is-date/@isDate.js +2 -2
- package/dist/src/{addon/validation → core/validation/validators}/is-not-empty/@isNotEmpty.js +2 -2
- package/dist/src/{addon/validation → core/validation/validators}/is-number/@isNumber.js +2 -2
- package/dist/src/{addon/validation → core/validation/validators}/is-present/@isPresent.js +2 -2
- package/dist/src/{addon/validation → core/validation/validators}/is-string/@isString.js +2 -2
- package/dist/src/{addon/validation → core/validation/validators}/max/@max.js +2 -2
- package/dist/src/{addon/validation → core/validation/validators}/min/@min.js +2 -2
- package/dist/src/feature/chat-bot/ChatBot.js +4 -0
- package/dist/src/{addon → feature}/money/MoneyDto.js +2 -2
- package/dist/src/{addon/repository → feature}/pg/PgCrudRepository.js +1 -1
- package/dist/src/feature/socket-controller/metadata/@connectionMiddleware.js +16 -0
- package/dist/src/feature/socket-controller/metadata/@socketConnection.js +18 -0
- package/dist/src/feature/socket-controller/metadata/@socketController.js +15 -0
- package/dist/src/feature/socket-controller/metadata/@socketEvent.js +18 -0
- package/dist/src/feature/socket-controller/metadata/SocketControllerMetadataStore.js +65 -0
- package/dist/src/feature/socket-controller/runSocketControllers.js +98 -0
- package/dist/src/index.d.ts +546 -368
- package/dist/src/index.js +53 -36
- package/package.json +1 -1
- package/dist/src/addon/chat-controller/whatsapp/WabotDevConnection.js +0 -57
- package/dist/src/addon/chat-controller/whatsapp/WabotDevSocketContracts.js +0 -10
- package/dist/src/addon/chat-controller/whatsapp/WhatsAppReceiverByDevConnection.js +0 -26
- package/dist/src/addon/chat-controller/whatsapp/WhatsAppReceiverByWebHook.js +0 -57
- package/dist/src/addon/chat-controller/whatsapp/WhatsAppSenderByDevConnection.js +0 -60
- package/dist/src/addon/{rest-controller → auth}/jwt/@jwtGuard.js +0 -0
- package/dist/src/addon/{rest-controller → auth}/jwt/Jwt.js +0 -0
- package/dist/src/addon/{rest-controller → auth}/jwt/JwtAccessAndRefreshTokenDto.js +0 -0
- package/dist/src/addon/{rest-controller → auth}/jwt/JwtConfig.js +0 -0
- package/dist/src/addon/{rest-controller → auth}/jwt/JwtGuardMiddleware.js +1 -1
- /package/dist/src/addon/{rest-controller → auth}/jwt/JwtRefreshToken.js +0 -0
- /package/dist/src/addon/{rest-controller → auth}/jwt/JwtSigner.js +0 -0
- /package/dist/src/core/validation/{validators → core}/validateArray.js +0 -0
- /package/dist/src/core/validation/{validators → core}/validateIsOptional.js +0 -0
- /package/dist/src/core/validation/{validators → core}/validateModel.js +0 -0
- /package/dist/src/{addon/validation → core/validation/validators}/is-boolean/validateIsBoolean.js +0 -0
- /package/dist/src/{addon/validation → core/validation/validators}/is-date/validateIsDate.js +0 -0
- /package/dist/src/{addon/validation → core/validation/validators}/is-not-empty/validateIsNotEmpty.js +0 -0
- /package/dist/src/{addon/validation → core/validation/validators}/is-number/validateIsNumber.js +0 -0
- /package/dist/src/{addon/validation → core/validation/validators}/is-present/validateIsPresent.js +0 -0
- /package/dist/src/{addon/validation → core/validation/validators}/is-string/validateIsString.js +0 -0
- /package/dist/src/{addon/validation → core/validation/validators}/max/validateMax.js +0 -0
- /package/dist/src/{addon/validation → core/validation/validators}/min/validateMin.js +0 -0
- /package/dist/src/{addon/repository → feature}/pg/PgRepositoryBase.js +0 -0
package/dist/src/index.js
CHANGED
|
@@ -5,16 +5,33 @@ export { CustomError } from './core/error/CustomError.js';
|
|
|
5
5
|
export { Lifecycle, container, inject, injectable, scoped, singleton } from './core/injection/index.js';
|
|
6
6
|
export { Logger } from './core/logger/Logger.js';
|
|
7
7
|
export { Mapper } from './core/mapper/Mapper.js';
|
|
8
|
+
export { Password } from './core/password/Password.js';
|
|
8
9
|
export { Random } from './core/random/Random.js';
|
|
9
10
|
export { Storable } from './core/storable/Storable.js';
|
|
10
11
|
export { isModel } from './core/validation/metadata/@isModel.js';
|
|
11
12
|
export { isOptional } from './core/validation/metadata/@isOptional.js';
|
|
12
13
|
export { isArray } from './core/validation/metadata/@isArray.js';
|
|
13
14
|
export { ValidationMetadataStore } from './core/validation/metadata/ValidationMetadataStore.js';
|
|
14
|
-
export { validateModel } from './core/validation/
|
|
15
|
-
export { validateArray } from './core/validation/
|
|
15
|
+
export { validateModel } from './core/validation/core/validateModel.js';
|
|
16
|
+
export { validateArray } from './core/validation/core/validateArray.js';
|
|
16
17
|
export { validate } from './core/validation/validate.js';
|
|
17
18
|
export { modelInfo } from './core/validation/modelInfo.js';
|
|
19
|
+
export { isBoolean } from './core/validation/validators/is-boolean/@isBoolean.js';
|
|
20
|
+
export { validateIsBoolean } from './core/validation/validators/is-boolean/validateIsBoolean.js';
|
|
21
|
+
export { isDate } from './core/validation/validators/is-date/@isDate.js';
|
|
22
|
+
export { validateIsDate } from './core/validation/validators/is-date/validateIsDate.js';
|
|
23
|
+
export { isNotEmpty } from './core/validation/validators/is-not-empty/@isNotEmpty.js';
|
|
24
|
+
export { validateIsNotEmpty } from './core/validation/validators/is-not-empty/validateIsNotEmpty.js';
|
|
25
|
+
export { isNumber } from './core/validation/validators/is-number/@isNumber.js';
|
|
26
|
+
export { validateIsNumber } from './core/validation/validators/is-number/validateIsNumber.js';
|
|
27
|
+
export { isPresent } from './core/validation/validators/is-present/@isPresent.js';
|
|
28
|
+
export { validateIsPresent } from './core/validation/validators/is-present/validateIsPresent.js';
|
|
29
|
+
export { isString } from './core/validation/validators/is-string/@isString.js';
|
|
30
|
+
export { validateIsString } from './core/validation/validators/is-string/validateIsString.js';
|
|
31
|
+
export { min } from './core/validation/validators/min/@min.js';
|
|
32
|
+
export { validateMin } from './core/validation/validators/min/validateMin.js';
|
|
33
|
+
export { max } from './core/validation/validators/max/@max.js';
|
|
34
|
+
export { validateMax } from './core/validation/validators/max/validateMax.js';
|
|
18
35
|
export { command } from './feature/async/@command.js';
|
|
19
36
|
export { commandHandler } from './feature/async/@commandHandler.js';
|
|
20
37
|
export { Async } from './feature/async/Async.js';
|
|
@@ -51,6 +68,10 @@ export { PARAM_DECORATION_IS_OPTIONAL, PARAM_DECORATION_PARAM } from './feature/
|
|
|
51
68
|
export { MindsetMetadataStore } from './feature/mindset/metadata/MindsetMetadataStore.js';
|
|
52
69
|
export { Mindset } from './feature/mindset/IMindset.js';
|
|
53
70
|
export { MindsetOperator } from './feature/mindset/MindsetOperator.js';
|
|
71
|
+
export { Money } from './feature/money/Money.js';
|
|
72
|
+
export { MoneyDto } from './feature/money/MoneyDto.js';
|
|
73
|
+
export { PgCrudRepository } from './feature/pg/PgCrudRepository.js';
|
|
74
|
+
export { PgRepositoryBase } from './feature/pg/PgRepositoryBase.js';
|
|
54
75
|
export { get } from './feature/rest-controller/metadata/@get.js';
|
|
55
76
|
export { middleware } from './feature/rest-controller/metadata/@middleware.js';
|
|
56
77
|
export { post } from './feature/rest-controller/metadata/@post.js';
|
|
@@ -59,8 +80,30 @@ export { RestControllerMetadataStore } from './feature/rest-controller/metadata/
|
|
|
59
80
|
export { runRestControllers } from './feature/rest-controller/runRestControllers.js';
|
|
60
81
|
export { EXPRESS_REQ, EXPRESS_RES } from './feature/rest-controller/injection-tokens.js';
|
|
61
82
|
export { SocketServerProvider } from './feature/socket/SocketServerProvider.js';
|
|
62
|
-
export {
|
|
83
|
+
export { connectionMiddleware } from './feature/socket-controller/metadata/@connectionMiddleware.js';
|
|
84
|
+
export { socketConnection } from './feature/socket-controller/metadata/@socketConnection.js';
|
|
85
|
+
export { socketController } from './feature/socket-controller/metadata/@socketController.js';
|
|
86
|
+
export { socketEvent } from './feature/socket-controller/metadata/@socketEvent.js';
|
|
87
|
+
export { SocketControllerMetadataStore } from './feature/socket-controller/metadata/SocketControllerMetadataStore.js';
|
|
88
|
+
export { runSocketControllers } from './feature/socket-controller/runSocketControllers.js';
|
|
63
89
|
export { PgJobRepository } from './addon/async/pg/PgJobRepository.js';
|
|
90
|
+
export { apiKeyGuard } from './addon/auth/api-key/@apiKeyGuard.js';
|
|
91
|
+
export { ApiKey } from './addon/auth/api-key/ApiKey.js';
|
|
92
|
+
export { ApiKeyGuardMiddleware } from './addon/auth/api-key/ApiKeyGuardMiddleware.js';
|
|
93
|
+
export { ApiKeyRepository } from './addon/auth/api-key/ApiKeyRepository.js';
|
|
94
|
+
export { PgApiKeyRepository } from './addon/auth/api-key/PgApiKeyRepository.js';
|
|
95
|
+
export { jwtConnectionGuard } from './addon/auth/jwt/@jwtConnectionGuard.js';
|
|
96
|
+
export { jwtGuard } from './addon/auth/jwt/@jwtGuard.js';
|
|
97
|
+
export { Jwt } from './addon/auth/jwt/Jwt.js';
|
|
98
|
+
export { JwtAccessAndRefreshTokenDto } from './addon/auth/jwt/JwtAccessAndRefreshTokenDto.js';
|
|
99
|
+
export { JwtConfig } from './addon/auth/jwt/JwtConfig.js';
|
|
100
|
+
export { JwtConnectionGuardMiddleware } from './addon/auth/jwt/JwtConnectionGuardMiddleware.js';
|
|
101
|
+
export { JwtGuardMiddleware } from './addon/auth/jwt/JwtGuardMiddleware.js';
|
|
102
|
+
export { JwtRefreshToken } from './addon/auth/jwt/JwtRefreshToken.js';
|
|
103
|
+
export { JwtRefreshTokenRepository } from './addon/auth/jwt/JwtRefreshTokenRepository.js';
|
|
104
|
+
export { JwtSigner } from './addon/auth/jwt/JwtSigner.js';
|
|
105
|
+
export { JwtTokenDto } from './addon/auth/jwt/JwtTokenDto.js';
|
|
106
|
+
export { PgJwtRefreshTokenRepository } from './addon/auth/jwt/PgJwtRefreshTokenRepository.js';
|
|
64
107
|
export { AnthropicChatAdapter } from './addon/chat-bot/anthropic/AnthropicChatAdapter.js';
|
|
65
108
|
export { DeepSeekChatAdapter } from './addon/chat-bot/deepseek/DeepSeekChatAdapter.js';
|
|
66
109
|
export { GoogleChatAdapter } from './addon/chat-bot/google/GoogleChatAdapter.js';
|
|
@@ -78,46 +121,20 @@ export { SocketChannelConfig } from './addon/chat-controller/socket/SocketChanne
|
|
|
78
121
|
export { telegram } from './addon/chat-controller/telegram/@telegram.js';
|
|
79
122
|
export { TelegramChannelConfig } from './addon/chat-controller/telegram/TelegramChannelConfig.js';
|
|
80
123
|
export { TelegramChannel } from './addon/chat-controller/telegram/TelegramChannel.js';
|
|
81
|
-
export {
|
|
124
|
+
export { whatsApp } from './addon/chat-controller/whatsapp/@whatsApp.js';
|
|
82
125
|
export { EnvWhatsAppRepository } from './addon/chat-controller/whatsapp/EnvWhatsAppRepository.js';
|
|
83
126
|
export { PgWhatsAppRepository } from './addon/chat-controller/whatsapp/PgWhatsAppRepository.js';
|
|
84
127
|
export { WhatsApp } from './addon/chat-controller/whatsapp/WhatsApp.js';
|
|
85
128
|
export { WhatsAppChannel } from './addon/chat-controller/whatsapp/WhatsAppChannel.js';
|
|
86
129
|
export { WhatsappChannelConfig } from './addon/chat-controller/whatsapp/WhatsAppChannelConfig.js';
|
|
87
130
|
export { WhatsAppReceiver } from './addon/chat-controller/whatsapp/WhatsAppReceiver.js';
|
|
88
|
-
export { WhatsAppReceiverByDevConnection } from './addon/chat-controller/whatsapp/WhatsAppReceiverByDevConnection.js';
|
|
89
|
-
export { WhatsAppReceiverByWebHook } from './addon/chat-controller/whatsapp/WhatsAppReceiverByWebHook.js';
|
|
90
131
|
export { WhatsAppRepository } from './addon/chat-controller/whatsapp/WhatsAppRepository.js';
|
|
91
132
|
export { WhatsAppSender } from './addon/chat-controller/whatsapp/WhatsAppSender.js';
|
|
92
|
-
export {
|
|
93
|
-
export {
|
|
133
|
+
export { WhatsAppReceiverByCloudApi } from './addon/chat-controller/whatsapp/cloud-api/WhatsAppReceiverByCloudApi.js';
|
|
134
|
+
export { WhatsAppSenderByCloudApi } from './addon/chat-controller/whatsapp/cloud-api/WhatsAppSenderByCloudApi.js';
|
|
135
|
+
export { WHATSAPP_MESSAGE_EVENT, WHATSAPP_PROXY_LISTEN_MESSAGE_EVENT, WHATSAPP_PROXY_SEND_MESSAGE_EVENT } from './addon/chat-controller/whatsapp/proxy/WhatsAppProxyContracts.js';
|
|
136
|
+
export { WhatsAppReceiverByWabotProxy } from './addon/chat-controller/whatsapp/proxy/WhatsAppReceiverByWabotProxy.js';
|
|
137
|
+
export { WhatsAppSenderByWabotProxy } from './addon/chat-controller/whatsapp/proxy/WhatsAppSenderByWabotProxy.js';
|
|
138
|
+
export { WhatsAppWabotProxyConnection } from './addon/chat-controller/whatsapp/proxy/WhatsAppWabotProxyConnection.js';
|
|
94
139
|
export { HtmlModule } from './addon/mindset/html/HtmlModule.js';
|
|
95
|
-
export { PgCrudRepository } from './addon/repository/pg/PgCrudRepository.js';
|
|
96
|
-
export { PgRepositoryBase } from './addon/repository/pg/PgRepositoryBase.js';
|
|
97
|
-
export { jwtGuard } from './addon/rest-controller/jwt/@jwtGuard.js';
|
|
98
|
-
export { JwtAccessAndRefreshTokenDto } from './addon/rest-controller/jwt/JwtAccessAndRefreshTokenDto.js';
|
|
99
|
-
export { JwtConfig } from './addon/rest-controller/jwt/JwtConfig.js';
|
|
100
|
-
export { Jwt } from './addon/rest-controller/jwt/Jwt.js';
|
|
101
|
-
export { JwtGuardMiddleware } from './addon/rest-controller/jwt/JwtGuardMiddleware.js';
|
|
102
|
-
export { JwtRefreshToken } from './addon/rest-controller/jwt/JwtRefreshToken.js';
|
|
103
|
-
export { JwtSigner } from './addon/rest-controller/jwt/JwtSigner.js';
|
|
104
|
-
export { JwtTokenDto } from './addon/rest-controller/jwt/JwtTokenDto.js';
|
|
105
|
-
export { JwtRefreshTokenRepository } from './addon/rest-controller/jwt/JwtRefreshTokenRepository.js';
|
|
106
|
-
export { isBoolean } from './addon/validation/is-boolean/@isBoolean.js';
|
|
107
|
-
export { validateIsBoolean } from './addon/validation/is-boolean/validateIsBoolean.js';
|
|
108
|
-
export { isDate } from './addon/validation/is-date/@isDate.js';
|
|
109
|
-
export { validateIsDate } from './addon/validation/is-date/validateIsDate.js';
|
|
110
|
-
export { isNotEmpty } from './addon/validation/is-not-empty/@isNotEmpty.js';
|
|
111
|
-
export { validateIsNotEmpty } from './addon/validation/is-not-empty/validateIsNotEmpty.js';
|
|
112
|
-
export { isNumber } from './addon/validation/is-number/@isNumber.js';
|
|
113
|
-
export { validateIsNumber } from './addon/validation/is-number/validateIsNumber.js';
|
|
114
|
-
export { isPresent } from './addon/validation/is-present/@isPresent.js';
|
|
115
|
-
export { validateIsPresent } from './addon/validation/is-present/validateIsPresent.js';
|
|
116
|
-
export { isString } from './addon/validation/is-string/@isString.js';
|
|
117
|
-
export { validateIsString } from './addon/validation/is-string/validateIsString.js';
|
|
118
|
-
export { min } from './addon/validation/min/@min.js';
|
|
119
|
-
export { validateMin } from './addon/validation/min/validateMin.js';
|
|
120
|
-
export { max } from './addon/validation/max/@max.js';
|
|
121
|
-
export { validateMax } from './addon/validation/max/validateMax.js';
|
|
122
|
-
export { MoneyDto } from './addon/money/MoneyDto.js';
|
|
123
140
|
export { Container } from './core/injection/Container.js';
|
package/package.json
CHANGED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { __decorate, __metadata } from 'tslib';
|
|
2
|
-
import { singleton } from '../../../core/injection/index.js';
|
|
3
|
-
import { Logger } from '../../../core/logger/Logger.js';
|
|
4
|
-
import { io } from 'socket.io-client';
|
|
5
|
-
import { devEmitEvent } from './WabotDevSocketContracts.js';
|
|
6
|
-
|
|
7
|
-
var WabotDevConnection_1;
|
|
8
|
-
let WabotDevConnection = WabotDevConnection_1 = class WabotDevConnection {
|
|
9
|
-
devProxy;
|
|
10
|
-
devProxySocket = null;
|
|
11
|
-
devToken;
|
|
12
|
-
logger = new Logger('wabot:dev-connection');
|
|
13
|
-
static isTokenAvailable() {
|
|
14
|
-
return !!process.env.WABOT_DEV_TOKEN;
|
|
15
|
-
}
|
|
16
|
-
constructor() {
|
|
17
|
-
if (!WabotDevConnection_1.isTokenAvailable()) {
|
|
18
|
-
throw new Error('WABOT_DEV_TOKEN is not set in environment variables');
|
|
19
|
-
}
|
|
20
|
-
this.devToken = process.env.WABOT_DEV_TOKEN;
|
|
21
|
-
this.devProxy = process.env.WABOT_DEV_PROXY ?? 'https://proxy.wabot.dev';
|
|
22
|
-
}
|
|
23
|
-
async getSocket() {
|
|
24
|
-
if (this.devProxySocket) {
|
|
25
|
-
return this.devProxySocket;
|
|
26
|
-
}
|
|
27
|
-
return new Promise((resolve, reject) => {
|
|
28
|
-
const devProxySocket = io(this.devProxy, { autoConnect: false });
|
|
29
|
-
devProxySocket.on('connect', async () => {
|
|
30
|
-
try {
|
|
31
|
-
const req = {
|
|
32
|
-
token: this.devToken,
|
|
33
|
-
};
|
|
34
|
-
this.logger.debug('dev connection request');
|
|
35
|
-
const ack = await devProxySocket.emitWithAck(devEmitEvent.DEV_CONNECTION, req);
|
|
36
|
-
if (ack != 'OK') {
|
|
37
|
-
return reject(new Error('Dev connection failed'));
|
|
38
|
-
}
|
|
39
|
-
this.logger.debug('success dev connection');
|
|
40
|
-
this.devProxySocket = devProxySocket;
|
|
41
|
-
resolve(devProxySocket);
|
|
42
|
-
}
|
|
43
|
-
catch (err) {
|
|
44
|
-
this.logger.error(err);
|
|
45
|
-
reject(err);
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
devProxySocket.connect();
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
WabotDevConnection = WabotDevConnection_1 = __decorate([
|
|
53
|
-
singleton(),
|
|
54
|
-
__metadata("design:paramtypes", [])
|
|
55
|
-
], WabotDevConnection);
|
|
56
|
-
|
|
57
|
-
export { WabotDevConnection };
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
const devListentEvent = {
|
|
2
|
-
DEV_WATSAPP_WEBHOOK: 'dev-whatsapp-webhook',
|
|
3
|
-
};
|
|
4
|
-
const devEmitEvent = {
|
|
5
|
-
DEV_CONNECTION: 'dev-connection',
|
|
6
|
-
DEV_SEND_WHATSAPP: 'dev-send-whatsapp',
|
|
7
|
-
DEV_SEND_WHATSAPP_TEMPLATE: 'dev-send-whatsapp-template',
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export { devEmitEvent, devListentEvent };
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { __decorate, __metadata } from 'tslib';
|
|
2
|
-
import { Logger } from '../../../core/logger/Logger.js';
|
|
3
|
-
import { WhatsAppReceiver } from './WhatsAppReceiver.js';
|
|
4
|
-
import { WabotDevConnection } from './WabotDevConnection.js';
|
|
5
|
-
import { devListentEvent } from './WabotDevSocketContracts.js';
|
|
6
|
-
import { singleton } from '../../../core/injection/index.js';
|
|
7
|
-
|
|
8
|
-
let WhatsAppReceiverByDevConnection = class WhatsAppReceiverByDevConnection extends WhatsAppReceiver {
|
|
9
|
-
wabotDevConnection;
|
|
10
|
-
constructor(wabotDevConnection) {
|
|
11
|
-
super(new Logger('wabot:whatsapp-receiver-by-dev-connection'));
|
|
12
|
-
this.wabotDevConnection = wabotDevConnection;
|
|
13
|
-
}
|
|
14
|
-
async connect() {
|
|
15
|
-
const socket = await this.wabotDevConnection.getSocket();
|
|
16
|
-
socket.on(devListentEvent.DEV_WATSAPP_WEBHOOK, (payload) => {
|
|
17
|
-
this.handlePayload(payload);
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
WhatsAppReceiverByDevConnection = __decorate([
|
|
22
|
-
singleton(),
|
|
23
|
-
__metadata("design:paramtypes", [WabotDevConnection])
|
|
24
|
-
], WhatsAppReceiverByDevConnection);
|
|
25
|
-
|
|
26
|
-
export { WhatsAppReceiverByDevConnection };
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { __decorate, __metadata } from 'tslib';
|
|
2
|
-
import { Logger } from '../../../core/logger/Logger.js';
|
|
3
|
-
import { WhatsAppReceiver } from './WhatsAppReceiver.js';
|
|
4
|
-
import { ExpressProvider } from '../../../feature/express/ExpressProvider.js';
|
|
5
|
-
import { json } from 'express';
|
|
6
|
-
import { WhatsAppRepository } from './WhatsAppRepository.js';
|
|
7
|
-
import { singleton } from '../../../core/injection/index.js';
|
|
8
|
-
|
|
9
|
-
let WhatsAppReceiverByWebHook = class WhatsAppReceiverByWebHook extends WhatsAppReceiver {
|
|
10
|
-
expressProvider;
|
|
11
|
-
whatsAppRepository;
|
|
12
|
-
expressApp;
|
|
13
|
-
webhookPath = '/whatsapp/web-hook/:slug';
|
|
14
|
-
constructor(expressProvider, whatsAppRepository) {
|
|
15
|
-
super(new Logger('wabot:whatsapp-receiver-by-webhook'));
|
|
16
|
-
this.expressProvider = expressProvider;
|
|
17
|
-
this.whatsAppRepository = whatsAppRepository;
|
|
18
|
-
this.expressApp = this.expressProvider.getExpress();
|
|
19
|
-
}
|
|
20
|
-
async connect() {
|
|
21
|
-
this.expressApp.get(this.webhookPath, json(), async (req, res) => {
|
|
22
|
-
try {
|
|
23
|
-
let mode = req.query['hub.mode'];
|
|
24
|
-
let token = req.query['hub.verify_token'];
|
|
25
|
-
let challenge = req.query['hub.challenge'];
|
|
26
|
-
if (!mode || !token || !challenge) {
|
|
27
|
-
res.sendStatus(400);
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
const whatsApp = await this.whatsAppRepository.findBySlug(req.params.slug);
|
|
31
|
-
if (!whatsApp || mode !== 'subscribe' || token !== whatsApp.getVerifyToken()) {
|
|
32
|
-
res.sendStatus(403);
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
res.status(200).send(challenge);
|
|
36
|
-
}
|
|
37
|
-
catch (e) {
|
|
38
|
-
this.logger.error(e);
|
|
39
|
-
res.sendStatus(500);
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
this.expressApp.post(this.webhookPath, json(), (req, res) => {
|
|
44
|
-
const payload = req.body;
|
|
45
|
-
this.handlePayload(payload);
|
|
46
|
-
res.sendStatus(200);
|
|
47
|
-
});
|
|
48
|
-
this.expressProvider.listen();
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
WhatsAppReceiverByWebHook = __decorate([
|
|
52
|
-
singleton(),
|
|
53
|
-
__metadata("design:paramtypes", [ExpressProvider,
|
|
54
|
-
WhatsAppRepository])
|
|
55
|
-
], WhatsAppReceiverByWebHook);
|
|
56
|
-
|
|
57
|
-
export { WhatsAppReceiverByWebHook };
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { __decorate, __metadata } from 'tslib';
|
|
2
|
-
import { WhatsAppSender } from './WhatsAppSender.js';
|
|
3
|
-
import { singleton } from '../../../core/injection/index.js';
|
|
4
|
-
import '../../../feature/chat-controller/metadata/ControllerMetadataStore.js';
|
|
5
|
-
import { ChatResolver } from '../../../feature/chat-controller/ChatResolver.js';
|
|
6
|
-
import '../../../feature/chat-bot/ChatBot.js';
|
|
7
|
-
import { ChatRepository } from '../../../feature/chat-bot/ChatRepository.js';
|
|
8
|
-
import 'uuid';
|
|
9
|
-
import '../../../feature/chat-bot/metadata/ChatBotMetadataStore.js';
|
|
10
|
-
import 'reflect-metadata';
|
|
11
|
-
import '../../../feature/mindset/metadata/MindsetMetadataStore.js';
|
|
12
|
-
import '../../../feature/mindset/MindsetOperator.js';
|
|
13
|
-
import { Logger } from '../../../core/logger/Logger.js';
|
|
14
|
-
import { WhatsAppRepository } from './WhatsAppRepository.js';
|
|
15
|
-
import { WabotDevConnection } from './WabotDevConnection.js';
|
|
16
|
-
import { devEmitEvent } from './WabotDevSocketContracts.js';
|
|
17
|
-
|
|
18
|
-
let WhatsAppSenderByDevConnection = class WhatsAppSenderByDevConnection extends WhatsAppSender {
|
|
19
|
-
wabotDevConnection;
|
|
20
|
-
constructor(wabotDevConnection, chatRepository, chatResolver, whatsAppRepository) {
|
|
21
|
-
super(new Logger('wabot:whatsapp-sender-by-dev-connection'), chatRepository, chatResolver, whatsAppRepository);
|
|
22
|
-
this.wabotDevConnection = wabotDevConnection;
|
|
23
|
-
}
|
|
24
|
-
async handleSendRequest(request) {
|
|
25
|
-
const socket = await this.wabotDevConnection.getSocket();
|
|
26
|
-
const req = {
|
|
27
|
-
from: request.from,
|
|
28
|
-
to: request.to,
|
|
29
|
-
message: request.message,
|
|
30
|
-
};
|
|
31
|
-
const ack = await socket.emitWithAck(devEmitEvent.DEV_SEND_WHATSAPP, req);
|
|
32
|
-
if (ack != 'OK') {
|
|
33
|
-
throw new Error(`Error sending WhatsApp template: ${ack}`);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
async handleSendTemplateRequest(request) {
|
|
37
|
-
const socket = await this.wabotDevConnection.getSocket();
|
|
38
|
-
const req = {
|
|
39
|
-
from: request.from,
|
|
40
|
-
to: request.to,
|
|
41
|
-
message: request.templateMessage,
|
|
42
|
-
};
|
|
43
|
-
const ack = await socket.emitWithAck(devEmitEvent.DEV_SEND_WHATSAPP_TEMPLATE, req);
|
|
44
|
-
if (ack != 'OK') {
|
|
45
|
-
throw new Error(`Error sending WhatsApp template: ${ack}`);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
async handleGetWhatsAppTemplate(request) {
|
|
49
|
-
throw new Error('Not implemented');
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
WhatsAppSenderByDevConnection = __decorate([
|
|
53
|
-
singleton(),
|
|
54
|
-
__metadata("design:paramtypes", [WabotDevConnection,
|
|
55
|
-
ChatRepository,
|
|
56
|
-
ChatResolver,
|
|
57
|
-
WhatsAppRepository])
|
|
58
|
-
], WhatsAppSenderByDevConnection);
|
|
59
|
-
|
|
60
|
-
export { WhatsAppSenderByDevConnection };
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -2,8 +2,8 @@ import { __decorate, __metadata } from 'tslib';
|
|
|
2
2
|
import { CustomError } from '../../../core/error/CustomError.js';
|
|
3
3
|
import { injectable } from '../../../core/injection/index.js';
|
|
4
4
|
import jwt from 'jsonwebtoken';
|
|
5
|
-
import { JwtConfig } from './JwtConfig.js';
|
|
6
5
|
import { Auth } from '../../../core/auth/Auth.js';
|
|
6
|
+
import { JwtConfig } from './JwtConfig.js';
|
|
7
7
|
|
|
8
8
|
let JwtGuardMiddleware = class JwtGuardMiddleware {
|
|
9
9
|
config;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/src/{addon/validation → core/validation/validators}/is-boolean/validateIsBoolean.js
RENAMED
|
File without changes
|
|
File without changes
|
/package/dist/src/{addon/validation → core/validation/validators}/is-not-empty/validateIsNotEmpty.js
RENAMED
|
File without changes
|
/package/dist/src/{addon/validation → core/validation/validators}/is-number/validateIsNumber.js
RENAMED
|
File without changes
|
/package/dist/src/{addon/validation → core/validation/validators}/is-present/validateIsPresent.js
RENAMED
|
File without changes
|
/package/dist/src/{addon/validation → core/validation/validators}/is-string/validateIsString.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|