@wabot-dev/framework 0.1.0-beta.67 → 0.1.0-beta.68
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,10 +1,14 @@
|
|
|
1
1
|
import { __decorate } from 'tslib';
|
|
2
2
|
import { injectable } from '../../../core/injection/index.js';
|
|
3
3
|
import * as readline from 'readline';
|
|
4
|
+
import * as fs from 'fs';
|
|
5
|
+
import * as path from 'path';
|
|
4
6
|
|
|
5
7
|
var CmdChannel_1;
|
|
6
8
|
const chatId = 'cmd';
|
|
9
|
+
const authInfoPath = '.cmd-channel/auth-info.json';
|
|
7
10
|
let CmdChannel = CmdChannel_1 = class CmdChannel {
|
|
11
|
+
authInfo = undefined;
|
|
8
12
|
rl = readline.createInterface({
|
|
9
13
|
input: process.stdin,
|
|
10
14
|
output: process.stdout,
|
|
@@ -31,6 +35,9 @@ let CmdChannel = CmdChannel_1 = class CmdChannel {
|
|
|
31
35
|
};
|
|
32
36
|
if (!this.callBack)
|
|
33
37
|
return;
|
|
38
|
+
if (this.authInfo === undefined) {
|
|
39
|
+
this.authInfo = readJsonFromFile(authInfoPath);
|
|
40
|
+
}
|
|
34
41
|
this.callBack({
|
|
35
42
|
chatConnection,
|
|
36
43
|
message: {
|
|
@@ -40,6 +47,11 @@ let CmdChannel = CmdChannel_1 = class CmdChannel {
|
|
|
40
47
|
console.log(`\n[${message.senderName}]: ${message.text}\n`);
|
|
41
48
|
this.rl.prompt();
|
|
42
49
|
},
|
|
50
|
+
authInfo: this.authInfo || undefined,
|
|
51
|
+
setAuthInfo: (authInfo) => {
|
|
52
|
+
this.authInfo = authInfo || null;
|
|
53
|
+
writeJsonToFile(authInfoPath, this.authInfo);
|
|
54
|
+
},
|
|
43
55
|
});
|
|
44
56
|
});
|
|
45
57
|
}
|
|
@@ -47,5 +59,22 @@ let CmdChannel = CmdChannel_1 = class CmdChannel {
|
|
|
47
59
|
CmdChannel = CmdChannel_1 = __decorate([
|
|
48
60
|
injectable()
|
|
49
61
|
], CmdChannel);
|
|
62
|
+
function writeJsonToFile(filename, data) {
|
|
63
|
+
const filePath = path.join(process.cwd(), filename);
|
|
64
|
+
fs.writeFileSync(filePath, JSON.stringify(data, null, 2), 'utf-8');
|
|
65
|
+
}
|
|
66
|
+
function readJsonFromFile(filename) {
|
|
67
|
+
const filePath = path.join(process.cwd(), filename);
|
|
68
|
+
if (!fs.existsSync(filePath)) {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
const jsonData = fs.readFileSync(filePath, 'utf-8');
|
|
72
|
+
try {
|
|
73
|
+
return JSON.parse(jsonData);
|
|
74
|
+
}
|
|
75
|
+
catch (err) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
50
79
|
|
|
51
|
-
export { CmdChannel };
|
|
80
|
+
export { CmdChannel, readJsonFromFile, writeJsonToFile };
|
|
@@ -5,7 +5,7 @@ import '../../core/validation/metadata/ValidationMetadataStore.js';
|
|
|
5
5
|
import { validate } from '../../core/validation/validate.js';
|
|
6
6
|
import { ExpressProvider } from '../express/ExpressProvider.js';
|
|
7
7
|
import { json, urlencoded } from 'express';
|
|
8
|
-
import
|
|
8
|
+
import path__default from 'path';
|
|
9
9
|
import { EXPRESS_REQ, EXPRESS_RES } from './injection-tokens.js';
|
|
10
10
|
import { RestControllerMetadataStore } from './metadata/RestControllerMetadataStore.js';
|
|
11
11
|
|
|
@@ -21,7 +21,7 @@ function runRestControllers(controllers) {
|
|
|
21
21
|
const endPoints = metadataStore.getControllerEndPointsInfo(controller);
|
|
22
22
|
endPoints.forEach((endPoint) => {
|
|
23
23
|
const method = endPoint.method;
|
|
24
|
-
const route =
|
|
24
|
+
const route = path__default
|
|
25
25
|
.join(endPoint.controller.path, endPoint.config?.path ?? '')
|
|
26
26
|
.replaceAll('\\', '/');
|
|
27
27
|
logger.info(`config ${endPoint.method.toUpperCase()} ${route}`);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SocketControllerMetadataStore } from './metadata/SocketControllerMetadataStore.js';
|
|
2
2
|
import { container } from '../../core/injection/index.js';
|
|
3
|
-
import
|
|
3
|
+
import path__default from 'path';
|
|
4
4
|
import { Logger } from '../../core/logger/Logger.js';
|
|
5
5
|
import { SocketServerProvider } from '../socket/SocketServerProvider.js';
|
|
6
6
|
import { CustomError } from '../../core/error/CustomError.js';
|
|
@@ -15,7 +15,7 @@ function runSocketControllers(controllers) {
|
|
|
15
15
|
controllers.forEach((controller) => {
|
|
16
16
|
const connections = metadataStore.getControllerSockerConnectionsInfo(controller);
|
|
17
17
|
connections.forEach((connection) => {
|
|
18
|
-
const namespace =
|
|
18
|
+
const namespace = path__default
|
|
19
19
|
.join(connection.controller.config?.namespace ?? '/', connection.config?.namespace ?? '')
|
|
20
20
|
.replaceAll('\\', '/');
|
|
21
21
|
logger.info(`config connection to ${namespace}`);
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1261,11 +1261,14 @@ declare class WabotChatAdapter implements IChatAdapter {
|
|
|
1261
1261
|
declare function cmd(): (target: object, propertyKey: string | symbol) => void;
|
|
1262
1262
|
|
|
1263
1263
|
declare class CmdChannel implements IChatChannel {
|
|
1264
|
+
private authInfo;
|
|
1264
1265
|
private rl;
|
|
1265
1266
|
private callBack;
|
|
1266
1267
|
listen(callback: (message: IChannelMessage) => void): void;
|
|
1267
1268
|
connect(): void;
|
|
1268
1269
|
}
|
|
1270
|
+
declare function writeJsonToFile<T>(filename: string, data: T): void;
|
|
1271
|
+
declare function readJsonFromFile<T>(filename: string): T | null;
|
|
1269
1272
|
|
|
1270
1273
|
interface ISocketChannelConfig {
|
|
1271
1274
|
channel: string;
|
|
@@ -1611,4 +1614,4 @@ declare function HtmlModule(options: IHtmlModuleOptions): {
|
|
|
1611
1614
|
new (): {};
|
|
1612
1615
|
};
|
|
1613
1616
|
|
|
1614
|
-
export { AnthropicChatAdapter, ApiKey, ApiKeyConnectionGuardMiddleware, ApiKeyGuardMiddleware, ApiKeyRepository, Async, Auth, Chat, ChatAdapter, ChatBot, ChatBotMetadataStore, ChatItem, ChatMemory, ChatRepository, ChatResolver, CmdChannel, Command, CommandMetadataStore, Container, ControllerMetadataStore, CustomError, DeepSeekChatAdapter, EXPRESS_REQ, EXPRESS_RES, Entity, Env, EnvWhatsAppRepository, ExpressProvider, GoogleChatAdapter, HtmlModule, HttpServerProvider, type IApiKeyData, type IApiKeyRepository, type IArrayValidationError, type IArrayValidationResult, type IBotMessageItem, type IChannelMessage, type IChannelMetadata, type IChatAdapter, type IChatAdapterNextItemReq, type IChatAdapterNextItemRes, type IChatBot, type IChatBotMetadata, type IChatChannel, type IChatConnection, type IChatControllerMetadata, type IChatData, type IChatItem, type IChatItemData, type IChatItemType, type IChatMemory, type IChatMessage, type IChatRepository, type IChatType, type ICommandConfig, type ICommandHandler, type ICommandHandlerConfig, type IConnectionMiddleware, type IConnectionMiddlewareMetadata, type IConstructor, type ICrudRepository, type ICustomErrorData, type IEndPointConfig, type IEndPointMetadata, type IEntityData, type IEnvType, type IFunctionCall, type IFunctionCallItem, type IGenerateApiKeyReq, type IGenerateApiKeyRes, type IGetWhatsAppTemplateRequest, type IHtmlModuleOptions, type IHumanMessageItem, type IJobData, type IJobEvent, type IJobEventListener, type IJobRepository, type IJwtRefreshTokenData, type IJwtRefreshTokenRepository, type ILanguageModelUsage, type IListenWhatsAppMessageRequest, type IMessageContext, type IMiddleware, type IMiddlewareMetadata, type IMindset, type IMindsetDecoration, type IMindsetFunctionConfig, type IMindsetFunctionDecoration, type IMindsetFunctionMetadata, type IMindsetFunctionParamMetadata, type IMindsetIdentity, type IMindsetLlm, type IMindsetMetadata, type IMindsetModuleConfig, type IMindsetModuleDecoration, type IMindsetModuleMetadata, type IMindsetTool, type IMindsetToolParameter, type IModelValidationError, type IModelValidationResult, type IModelValidatorsInfo, type IMoneyData, type IParamConfig, type IParamDecoration, type IPersistentData, type IPgRepositoryConfig, type IPrimitive, type IPropertyValidatorInfo, type IReceivedMessage, type IRestControllerConfig, type IRestControllerMetadata, type ISendWhatsAppRequest, type ISendWhatsAppTemplateRequest, type ISocketChannelConfig, type ISocketChannelReceivedMessage, type ISocketConnectionConfig, type ISocketConnectionMetadata, type ISocketControllerConfig, type ISocketControllerMetadata, type ISocketEventConfig, type ISocketEventMetadata, type IStorableData, type ITelegramChannelConfig, type IValidateArrayOptions, type IValidateArrayOptionsWithItemsValidators, type IValidateIsInOptions, type IValidateMaxOptions, type IValidateMinOptions, type IValidationError, type IValidationResult, type IValidator, type IValidatorMetadata, type IWhatsAppBusinessAccount, type IWhatsAppBusinessNumber, type IWhatsAppCloudContact, type IWhatsAppCloudMessage, type IWhatsAppCloudMessageMetadata, type IWhatsAppCloudTemplate, type IWhatsAppCloudTemplateComponent, type IWhatsAppCloudTemplateMessage, type IWhatsAppCloudTemplateParameter, type IWhatsAppCloudTemplateResponse, type IWhatsAppCloudWebhookPayload, type IWhatsAppData, type IWhatsAppMessageListener, type IWhatsAppProxyListenMessageEventData, type IWhatsAppProxyListenMessageEventReq, type IWhatsAppProxyMessage, type IWhatsAppProxyMessageContent, type IWhatsAppProxyMessageEventReq, type IWhatsAppProxySendMessageEventReq, type IWhatsAppRepository, type IWhatsAppSenderOptions, type IWhatsappChannelConfig, type IchatControllerConfig, Job, JobRepository, JobRunner, JobsEventsHub, Jwt, JwtAccessAndRefreshTokenDto, JwtConfig, JwtConnectionGuardMiddleware, JwtGuardMiddleware, JwtRefreshToken, JwtRefreshTokenRepository, JwtSigner, JwtTokenDto, Lifecycle, Logger, MINDSET_DECORATION_MINDSET, MINDSET_FUNCTION_DECORATION_FUNCTION, MINDSET_MODULE_DECORATION_MODULE, Mapper, Mindset, MindsetMetadataStore, MindsetOperator, Money, MoneyDto, OpenaiChatAdapter, PARAM_DECORATION_IS_OPTIONAL, PARAM_DECORATION_PARAM, Password, type PasswordHashOptions, Persistent, PgApiKeyRepository, PgChatMemory, PgChatRepository, PgCrudRepository, PgJobRepository, PgJwtRefreshTokenRepository, PgRepositoryBase, PgWhatsAppRepository, RamChatMemory, RamChatRepository, Random, RemoteApiKeyRepository, RestControllerMetadataStore, SocketChannel, SocketChannelConfig, SocketControllerMetadataStore, SocketServerProvider, Storable, TelegramChannel, TelegramChannelConfig, ValidationMetadataStore, WHATSAPP_MESSAGE_EVENT, WHATSAPP_PROXY_LISTEN_MESSAGE_EVENT, WHATSAPP_PROXY_SEND_MESSAGE_EVENT, WabotChatAdapter, WhatsApp, WhatsAppChannel, WhatsAppReceiver, WhatsAppReceiverByCloudApi, WhatsAppReceiverByWabotProxy, WhatsAppRepository, WhatsAppSender, WhatsAppSenderByCloudApi, WhatsAppSenderByWabotProxy, WhatsAppWabotProxyConnection, WhatsappChannelConfig, apiKeyConnectionGuard, apiKeyGuard, chatBot, chatController, chatItemTypeOptions, cmd, command, commandHandler, connectionMiddleware, container, inject, injectable, isArray, isBoolean, isDate, isIn, isModel, isNotEmpty, isNumber, isOptional, isPresent, isString, jwtConnectionGuard, jwtGuard, max, middleware, min, mindset, mindsetFunction, mindsetModule, modelInfo, onDelete, onGet, onPost, onPut, param, restController, runAsyncCommandHandlers, runChatControllers, runRestControllers, runSocketControllers, scoped, singleton, socket, socketConnection, socketController, socketEvent, telegram, validate, validateArray, validateIsBoolean, validateIsDate, validateIsIn, validateIsNotEmpty, validateIsNumber, validateIsPresent, validateIsString, validateMax, validateMin, validateModel, whatsApp };
|
|
1617
|
+
export { AnthropicChatAdapter, ApiKey, ApiKeyConnectionGuardMiddleware, ApiKeyGuardMiddleware, ApiKeyRepository, Async, Auth, Chat, ChatAdapter, ChatBot, ChatBotMetadataStore, ChatItem, ChatMemory, ChatRepository, ChatResolver, CmdChannel, Command, CommandMetadataStore, Container, ControllerMetadataStore, CustomError, DeepSeekChatAdapter, EXPRESS_REQ, EXPRESS_RES, Entity, Env, EnvWhatsAppRepository, ExpressProvider, GoogleChatAdapter, HtmlModule, HttpServerProvider, type IApiKeyData, type IApiKeyRepository, type IArrayValidationError, type IArrayValidationResult, type IBotMessageItem, type IChannelMessage, type IChannelMetadata, type IChatAdapter, type IChatAdapterNextItemReq, type IChatAdapterNextItemRes, type IChatBot, type IChatBotMetadata, type IChatChannel, type IChatConnection, type IChatControllerMetadata, type IChatData, type IChatItem, type IChatItemData, type IChatItemType, type IChatMemory, type IChatMessage, type IChatRepository, type IChatType, type ICommandConfig, type ICommandHandler, type ICommandHandlerConfig, type IConnectionMiddleware, type IConnectionMiddlewareMetadata, type IConstructor, type ICrudRepository, type ICustomErrorData, type IEndPointConfig, type IEndPointMetadata, type IEntityData, type IEnvType, type IFunctionCall, type IFunctionCallItem, type IGenerateApiKeyReq, type IGenerateApiKeyRes, type IGetWhatsAppTemplateRequest, type IHtmlModuleOptions, type IHumanMessageItem, type IJobData, type IJobEvent, type IJobEventListener, type IJobRepository, type IJwtRefreshTokenData, type IJwtRefreshTokenRepository, type ILanguageModelUsage, type IListenWhatsAppMessageRequest, type IMessageContext, type IMiddleware, type IMiddlewareMetadata, type IMindset, type IMindsetDecoration, type IMindsetFunctionConfig, type IMindsetFunctionDecoration, type IMindsetFunctionMetadata, type IMindsetFunctionParamMetadata, type IMindsetIdentity, type IMindsetLlm, type IMindsetMetadata, type IMindsetModuleConfig, type IMindsetModuleDecoration, type IMindsetModuleMetadata, type IMindsetTool, type IMindsetToolParameter, type IModelValidationError, type IModelValidationResult, type IModelValidatorsInfo, type IMoneyData, type IParamConfig, type IParamDecoration, type IPersistentData, type IPgRepositoryConfig, type IPrimitive, type IPropertyValidatorInfo, type IReceivedMessage, type IRestControllerConfig, type IRestControllerMetadata, type ISendWhatsAppRequest, type ISendWhatsAppTemplateRequest, type ISocketChannelConfig, type ISocketChannelReceivedMessage, type ISocketConnectionConfig, type ISocketConnectionMetadata, type ISocketControllerConfig, type ISocketControllerMetadata, type ISocketEventConfig, type ISocketEventMetadata, type IStorableData, type ITelegramChannelConfig, type IValidateArrayOptions, type IValidateArrayOptionsWithItemsValidators, type IValidateIsInOptions, type IValidateMaxOptions, type IValidateMinOptions, type IValidationError, type IValidationResult, type IValidator, type IValidatorMetadata, type IWhatsAppBusinessAccount, type IWhatsAppBusinessNumber, type IWhatsAppCloudContact, type IWhatsAppCloudMessage, type IWhatsAppCloudMessageMetadata, type IWhatsAppCloudTemplate, type IWhatsAppCloudTemplateComponent, type IWhatsAppCloudTemplateMessage, type IWhatsAppCloudTemplateParameter, type IWhatsAppCloudTemplateResponse, type IWhatsAppCloudWebhookPayload, type IWhatsAppData, type IWhatsAppMessageListener, type IWhatsAppProxyListenMessageEventData, type IWhatsAppProxyListenMessageEventReq, type IWhatsAppProxyMessage, type IWhatsAppProxyMessageContent, type IWhatsAppProxyMessageEventReq, type IWhatsAppProxySendMessageEventReq, type IWhatsAppRepository, type IWhatsAppSenderOptions, type IWhatsappChannelConfig, type IchatControllerConfig, Job, JobRepository, JobRunner, JobsEventsHub, Jwt, JwtAccessAndRefreshTokenDto, JwtConfig, JwtConnectionGuardMiddleware, JwtGuardMiddleware, JwtRefreshToken, JwtRefreshTokenRepository, JwtSigner, JwtTokenDto, Lifecycle, Logger, MINDSET_DECORATION_MINDSET, MINDSET_FUNCTION_DECORATION_FUNCTION, MINDSET_MODULE_DECORATION_MODULE, Mapper, Mindset, MindsetMetadataStore, MindsetOperator, Money, MoneyDto, OpenaiChatAdapter, PARAM_DECORATION_IS_OPTIONAL, PARAM_DECORATION_PARAM, Password, type PasswordHashOptions, Persistent, PgApiKeyRepository, PgChatMemory, PgChatRepository, PgCrudRepository, PgJobRepository, PgJwtRefreshTokenRepository, PgRepositoryBase, PgWhatsAppRepository, RamChatMemory, RamChatRepository, Random, RemoteApiKeyRepository, RestControllerMetadataStore, SocketChannel, SocketChannelConfig, SocketControllerMetadataStore, SocketServerProvider, Storable, TelegramChannel, TelegramChannelConfig, ValidationMetadataStore, WHATSAPP_MESSAGE_EVENT, WHATSAPP_PROXY_LISTEN_MESSAGE_EVENT, WHATSAPP_PROXY_SEND_MESSAGE_EVENT, WabotChatAdapter, WhatsApp, WhatsAppChannel, WhatsAppReceiver, WhatsAppReceiverByCloudApi, WhatsAppReceiverByWabotProxy, WhatsAppRepository, WhatsAppSender, WhatsAppSenderByCloudApi, WhatsAppSenderByWabotProxy, WhatsAppWabotProxyConnection, WhatsappChannelConfig, apiKeyConnectionGuard, apiKeyGuard, chatBot, chatController, chatItemTypeOptions, cmd, command, commandHandler, connectionMiddleware, container, inject, injectable, isArray, isBoolean, isDate, isIn, isModel, isNotEmpty, isNumber, isOptional, isPresent, isString, jwtConnectionGuard, jwtGuard, max, middleware, min, mindset, mindsetFunction, mindsetModule, modelInfo, onDelete, onGet, onPost, onPut, param, readJsonFromFile, restController, runAsyncCommandHandlers, runChatControllers, runRestControllers, runSocketControllers, scoped, singleton, socket, socketConnection, socketController, socketEvent, telegram, validate, validateArray, validateIsBoolean, validateIsDate, validateIsIn, validateIsNotEmpty, validateIsNumber, validateIsPresent, validateIsString, validateMax, validateMin, validateModel, whatsApp, writeJsonToFile };
|
package/dist/src/index.js
CHANGED
|
@@ -121,7 +121,7 @@ export { RamChatMemory } from './addon/chat-bot/ram/RamChatMemory.js';
|
|
|
121
121
|
export { RamChatRepository } from './addon/chat-bot/ram/RamChatRepository.js';
|
|
122
122
|
export { WabotChatAdapter } from './addon/chat-bot/wabot/WabotChatAdapter.js';
|
|
123
123
|
export { cmd } from './addon/chat-controller/cmd/@cmd.js';
|
|
124
|
-
export { CmdChannel } from './addon/chat-controller/cmd/CmdChannel.js';
|
|
124
|
+
export { CmdChannel, readJsonFromFile, writeJsonToFile } from './addon/chat-controller/cmd/CmdChannel.js';
|
|
125
125
|
export { socket } from './addon/chat-controller/socket/@socket.js';
|
|
126
126
|
export { SocketChannel } from './addon/chat-controller/socket/SocketChannel.js';
|
|
127
127
|
export { SocketChannelConfig } from './addon/chat-controller/socket/SocketChannelConfig.js';
|