@wabot-dev/framework 0.4.0-beta.5 → 0.4.0-beta.7
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/chat-bot/ram/RamChatRepository.js +6 -0
- package/dist/src/addon/chat-controller/whatsapp/proxy/WhatsAppReceiverByWabotProxy.js +1 -1
- package/dist/src/feature/chat-bot/Chat.js +17 -0
- package/dist/src/feature/chat-bot/ChatRepository.js +3 -0
- package/dist/src/index.d.ts +20 -2
- package/package.json +1 -1
|
@@ -6,6 +6,12 @@ import { singleton } from '../../../core/injection/index.js';
|
|
|
6
6
|
let RamChatRepository = class RamChatRepository {
|
|
7
7
|
items = [];
|
|
8
8
|
memories = [];
|
|
9
|
+
async update(chat) {
|
|
10
|
+
if (!chat.wasCreated()) {
|
|
11
|
+
throw new Error('Chat wat not created');
|
|
12
|
+
}
|
|
13
|
+
chat.validate();
|
|
14
|
+
}
|
|
9
15
|
async create(chat) {
|
|
10
16
|
if (chat.wasCreated()) {
|
|
11
17
|
throw new Error('Chat already created');
|
|
@@ -13,6 +13,9 @@ class Chat extends Entity {
|
|
|
13
13
|
get connections() {
|
|
14
14
|
return this.data.connections;
|
|
15
15
|
}
|
|
16
|
+
get associations() {
|
|
17
|
+
return this.data.associations ?? [];
|
|
18
|
+
}
|
|
16
19
|
hasConnection(connection) {
|
|
17
20
|
for (const con of this.data.connections) {
|
|
18
21
|
if (con.channelName === connection.channelName && con.id === connection.id) {
|
|
@@ -21,6 +24,20 @@ class Chat extends Entity {
|
|
|
21
24
|
}
|
|
22
25
|
return false;
|
|
23
26
|
}
|
|
27
|
+
hasAssociation(type, id) {
|
|
28
|
+
return this.data.associations?.some((a) => a.type === type && a.id === id) ?? false;
|
|
29
|
+
}
|
|
30
|
+
getAssociationsByType(type) {
|
|
31
|
+
return this.data.associations?.filter((a) => a.type === type) ?? [];
|
|
32
|
+
}
|
|
33
|
+
addAssociation(association) {
|
|
34
|
+
if (this.hasAssociation(association.type, association.id)) {
|
|
35
|
+
throw new Error('Association already exists');
|
|
36
|
+
}
|
|
37
|
+
if (!this.data.associations)
|
|
38
|
+
this.data.associations = [];
|
|
39
|
+
this.data.associations.push(association);
|
|
40
|
+
}
|
|
24
41
|
validatePrivateChat() {
|
|
25
42
|
if (this.data.connections.length < 1) {
|
|
26
43
|
throw new Error('PRIVATE chat should have one or more connections');
|
package/dist/src/index.d.ts
CHANGED
|
@@ -574,9 +574,14 @@ interface IChatConnection {
|
|
|
574
574
|
|
|
575
575
|
type IChatType = 'PRIVATE' | 'GROUP';
|
|
576
576
|
|
|
577
|
+
interface IChatAssociation {
|
|
578
|
+
type: string;
|
|
579
|
+
id: string;
|
|
580
|
+
}
|
|
577
581
|
interface IChatData extends IEntityData {
|
|
578
582
|
type: IChatType;
|
|
579
583
|
connections: IChatConnection[];
|
|
584
|
+
associations?: IChatAssociation[];
|
|
580
585
|
}
|
|
581
586
|
declare class Chat extends Entity<IChatData> {
|
|
582
587
|
constructor(data: IChatData);
|
|
@@ -587,7 +592,17 @@ declare class Chat extends Entity<IChatData> {
|
|
|
587
592
|
channelName: string;
|
|
588
593
|
id: string;
|
|
589
594
|
}[];
|
|
595
|
+
get associations(): {
|
|
596
|
+
type: string;
|
|
597
|
+
id: string;
|
|
598
|
+
}[];
|
|
590
599
|
hasConnection(connection: IChatConnection): boolean;
|
|
600
|
+
hasAssociation(type: string, id: string): boolean;
|
|
601
|
+
getAssociationsByType(type: string): {
|
|
602
|
+
type: string;
|
|
603
|
+
id: string;
|
|
604
|
+
}[];
|
|
605
|
+
addAssociation(association: IChatAssociation): void;
|
|
591
606
|
private validatePrivateChat;
|
|
592
607
|
private validateGroupChat;
|
|
593
608
|
validate(): void;
|
|
@@ -833,12 +848,14 @@ declare class ChatBot implements IChatBot {
|
|
|
833
848
|
|
|
834
849
|
interface IChatRepository {
|
|
835
850
|
create(chat: Chat): Promise<void>;
|
|
851
|
+
update(chat: Chat): Promise<void>;
|
|
836
852
|
findByConnection(query: IChatConnection): Promise<Chat | null>;
|
|
837
853
|
findMemory(chatId: string): Promise<IChatMemory | null>;
|
|
838
854
|
}
|
|
839
855
|
|
|
840
856
|
declare class ChatRepository implements IChatRepository {
|
|
841
857
|
create(chat: Chat): Promise<void>;
|
|
858
|
+
update(chat: Chat): Promise<void>;
|
|
842
859
|
findByConnection(query: IChatConnection): Promise<Chat | null>;
|
|
843
860
|
findMemory(chatId: string): Promise<IChatMemory | null>;
|
|
844
861
|
}
|
|
@@ -1465,6 +1482,7 @@ declare class RamChatMemory implements IChatMemory {
|
|
|
1465
1482
|
declare class RamChatRepository implements IChatRepository {
|
|
1466
1483
|
private items;
|
|
1467
1484
|
private memories;
|
|
1485
|
+
update(chat: Chat): Promise<void>;
|
|
1468
1486
|
create(chat: Chat): Promise<void>;
|
|
1469
1487
|
findByConnection(query: IChatConnection): Promise<Chat | null>;
|
|
1470
1488
|
findMemory(chatId: string): Promise<IChatMemory | null>;
|
|
@@ -1806,7 +1824,7 @@ interface IWhatsAppProxyListenMessageEventReq {
|
|
|
1806
1824
|
}
|
|
1807
1825
|
interface IWhatsAppProxyListenMessageEventData {
|
|
1808
1826
|
from?: string[];
|
|
1809
|
-
to: string
|
|
1827
|
+
to: string;
|
|
1810
1828
|
}
|
|
1811
1829
|
declare const WHATSAPP_MESSAGE_EVENT: "message";
|
|
1812
1830
|
interface IWhatsAppProxyMessageEventReq {
|
|
@@ -1846,4 +1864,4 @@ declare function HtmlModule(options: IHtmlModuleOptions): {
|
|
|
1846
1864
|
new (): {};
|
|
1847
1865
|
};
|
|
1848
1866
|
|
|
1849
|
-
export { AnthropicChatAdapter, ApiKey, ApiKeyGuardMiddleware, ApiKeyHandshakeGuardMiddleware, ApiKeyRepository, Async, AsyncMetadataStore, Auth, Chat, ChatAdapter, ChatBot, ChatBotMetadataStore, ChatItem, ChatMemory, ChatRepository, ChatResolver, type ClientMap, CmdChannel, Container, ControllerMetadataStore, CronJob, CronJobRepository, CustomError, DeepSeekChatAdapter, DescriptionMetadataStore, EXPRESS_REQ, EXPRESS_RES, Entity, Env, EnvWhatsAppRepository, ExpressProvider, GoogleChatAdapter, type GoogleChatAdapterV2Options, HtmlModule, HttpServerProvider, type IApiKeyData, type IApiKeyRepository, type IArrayValidationError, type IArrayValidationResult, type IBotMessageItem, type IChannelMessage, type IChannelMetadata, type IChatAdapter, type IChatAdapterNextItemsReq, type IChatAdapterNextItemsRes, 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 IConstructor, type ICronConfig, type ICronJobData, type ICrudRepository, type ICustomErrorData, type IDescriptionMetadata, type IEndPointConfig, type IEndPointMetadata, type IEntityData, type IEnvType, type IFunctionCall, type IFunctionCallItem, type IGenerateApiKeyReq, type IGenerateApiKeyRes, type IGetWhatsAppTemplateRequest, type IHandshakeMiddleware, type IHandshakeMiddlewareMetadata, type IHtmlModuleOptions, type IHumanMessageItem, type IJobData, type IJobRepository, type IJwtRefreshTokenData, type IJwtRefreshTokenRepository, type ILanguageModelUsage, type IListenWhatsAppMessageRequest, type ILockKey, type ILocker, type IMessageContext, type IMiddleware, type IMiddlewareMetadata, type IMindset, type IMindsetConfig, type IMindsetIdentity, type IMindsetLlm, type IMindsetMetadata, type IMindsetModuleConfig, type IMindsetModuleMetadata, type IMindsetTool, type IMindsetToolParameter, type IModelValidationError, type IModelValidationResult, type IModelValidatorsInfo, type IMoneyData, type IPersistentData, type IPgRepositoryConfig, type IPropertyValidatorInfo, type IReceivedMessage, type IRemoteApiKeyFetcher, type IRestControllerConfig, type IRestControllerMetadata, type ISendWhatsAppRequest, type ISendWhatsAppTemplateRequest, type ISocketChannelConfig, type ISocketChannelReceivedMessage, type ISocketControllerConfig, type ISocketControllerMetadata, type ISocketEventConfig, type ISocketEventMetadata, type IStorableData, type ITelegramChannelConfig, type IValidateArrayOptions, type IValidateArrayOptionsWithItemsValidators, type IValidateInputShape, type IValidateIsInOptions, type IValidateIsRecordOptions, 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, Jwt, JwtAccessAndRefreshTokenDto, JwtConfig, JwtGuardMiddleware, JwtHandshakeGuardMiddleware, JwtRefreshToken, JwtRefreshTokenRepository, JwtSigner, JwtTokenDto, Lifecycle, Locker, Logger, Mapper, Mindset, MindsetMetadataStore, MindsetOperator, Money, MoneyDto, OpenaiChatAdapter, Password, type PasswordHashOptions, Persistent, PgApiKeyRepository, PgChatMemory, PgChatRepository, PgCronJobRepository, PgCrudRepository, PgJobRepository, PgJwtRefreshTokenRepository, PgLockKey, PgLocker, PgRepositoryBase, PgWhatsAppRepository, RamChatMemory, RamChatRepository, Random, RemoteApiKeyRepository, RestControllerMetadataStore, RestRequest, SocketChannel, SocketChannelConfig, SocketChannelReceivedMessage, 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, apiKeyGuard, apiKeyHandshakeGuard, chatBot, chatController, chatItemTypeOptions, cmd, command, commandHandler, container, cron, description, getClientMap, getPgClient, handshakeMiddlewares, inject, injectable, isArray, isBoolean, isDate, isIn, isModel, isNotEmpty, isNumber, isOptional, isPresent, isRecord, isString, jwtGuard, jwtHandshakeGuard, max, middleware, min, mindset, mindsetModule, modelInfo, onDelete, onGet, onPost, onPut, onSocketEvent, pgStorage, readJsonFromFile, restController, runChatControllers, runCommandHandlers, runCronHandlers, runRestControllers, runSocketControllers, scoped, singleton, socket, socketController, stopCommandHandlers, stopCronHandlers, telegram, validateAndTransform, validateArray, validateIsBoolean, validateIsDate, validateIsIn, validateIsNotEmpty, validateIsNumber, validateIsPresent, validateIsRecord, validateIsString, validateMax, validateMin, validateModel, whatsApp, withPgClient, withPgTransaction, writeJsonToFile };
|
|
1867
|
+
export { AnthropicChatAdapter, ApiKey, ApiKeyGuardMiddleware, ApiKeyHandshakeGuardMiddleware, ApiKeyRepository, Async, AsyncMetadataStore, Auth, Chat, ChatAdapter, ChatBot, ChatBotMetadataStore, ChatItem, ChatMemory, ChatRepository, ChatResolver, type ClientMap, CmdChannel, Container, ControllerMetadataStore, CronJob, CronJobRepository, CustomError, DeepSeekChatAdapter, DescriptionMetadataStore, EXPRESS_REQ, EXPRESS_RES, Entity, Env, EnvWhatsAppRepository, ExpressProvider, GoogleChatAdapter, type GoogleChatAdapterV2Options, HtmlModule, HttpServerProvider, type IApiKeyData, type IApiKeyRepository, type IArrayValidationError, type IArrayValidationResult, type IBotMessageItem, type IChannelMessage, type IChannelMetadata, type IChatAdapter, type IChatAdapterNextItemsReq, type IChatAdapterNextItemsRes, type IChatAssociation, 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 IConstructor, type ICronConfig, type ICronJobData, type ICrudRepository, type ICustomErrorData, type IDescriptionMetadata, type IEndPointConfig, type IEndPointMetadata, type IEntityData, type IEnvType, type IFunctionCall, type IFunctionCallItem, type IGenerateApiKeyReq, type IGenerateApiKeyRes, type IGetWhatsAppTemplateRequest, type IHandshakeMiddleware, type IHandshakeMiddlewareMetadata, type IHtmlModuleOptions, type IHumanMessageItem, type IJobData, type IJobRepository, type IJwtRefreshTokenData, type IJwtRefreshTokenRepository, type ILanguageModelUsage, type IListenWhatsAppMessageRequest, type ILockKey, type ILocker, type IMessageContext, type IMiddleware, type IMiddlewareMetadata, type IMindset, type IMindsetConfig, type IMindsetIdentity, type IMindsetLlm, type IMindsetMetadata, type IMindsetModuleConfig, type IMindsetModuleMetadata, type IMindsetTool, type IMindsetToolParameter, type IModelValidationError, type IModelValidationResult, type IModelValidatorsInfo, type IMoneyData, type IPersistentData, type IPgRepositoryConfig, type IPropertyValidatorInfo, type IReceivedMessage, type IRemoteApiKeyFetcher, type IRestControllerConfig, type IRestControllerMetadata, type ISendWhatsAppRequest, type ISendWhatsAppTemplateRequest, type ISocketChannelConfig, type ISocketChannelReceivedMessage, type ISocketControllerConfig, type ISocketControllerMetadata, type ISocketEventConfig, type ISocketEventMetadata, type IStorableData, type ITelegramChannelConfig, type IValidateArrayOptions, type IValidateArrayOptionsWithItemsValidators, type IValidateInputShape, type IValidateIsInOptions, type IValidateIsRecordOptions, 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, Jwt, JwtAccessAndRefreshTokenDto, JwtConfig, JwtGuardMiddleware, JwtHandshakeGuardMiddleware, JwtRefreshToken, JwtRefreshTokenRepository, JwtSigner, JwtTokenDto, Lifecycle, Locker, Logger, Mapper, Mindset, MindsetMetadataStore, MindsetOperator, Money, MoneyDto, OpenaiChatAdapter, Password, type PasswordHashOptions, Persistent, PgApiKeyRepository, PgChatMemory, PgChatRepository, PgCronJobRepository, PgCrudRepository, PgJobRepository, PgJwtRefreshTokenRepository, PgLockKey, PgLocker, PgRepositoryBase, PgWhatsAppRepository, RamChatMemory, RamChatRepository, Random, RemoteApiKeyRepository, RestControllerMetadataStore, RestRequest, SocketChannel, SocketChannelConfig, SocketChannelReceivedMessage, 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, apiKeyGuard, apiKeyHandshakeGuard, chatBot, chatController, chatItemTypeOptions, cmd, command, commandHandler, container, cron, description, getClientMap, getPgClient, handshakeMiddlewares, inject, injectable, isArray, isBoolean, isDate, isIn, isModel, isNotEmpty, isNumber, isOptional, isPresent, isRecord, isString, jwtGuard, jwtHandshakeGuard, max, middleware, min, mindset, mindsetModule, modelInfo, onDelete, onGet, onPost, onPut, onSocketEvent, pgStorage, readJsonFromFile, restController, runChatControllers, runCommandHandlers, runCronHandlers, runRestControllers, runSocketControllers, scoped, singleton, socket, socketController, stopCommandHandlers, stopCronHandlers, telegram, validateAndTransform, validateArray, validateIsBoolean, validateIsDate, validateIsIn, validateIsNotEmpty, validateIsNumber, validateIsPresent, validateIsRecord, validateIsString, validateMax, validateMin, validateModel, whatsApp, withPgClient, withPgTransaction, writeJsonToFile };
|