@wabot-dev/framework 0.1.0-beta.2 → 0.1.0-beta.4
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/ai/deepseek/DeepSeekChatBotAdapter.js +3 -5
- package/dist/src/ai/openia/OpenaiChatBotAdapter.js +3 -5
- package/dist/src/channels/cmd/@cmd.js +0 -4
- package/dist/src/channels/cmd/CmdChannel.js +0 -4
- package/dist/src/channels/express/ExpressProvider.js +46 -0
- package/dist/src/channels/http/HttpServerProvider.js +31 -0
- package/dist/src/channels/{socket-io → socket}/@socket.js +0 -4
- package/dist/src/channels/{socket-io → socket}/SocketChannel.js +12 -11
- package/dist/src/channels/socket/SocketServerProvider.js +50 -0
- package/dist/src/channels/telegram/@telegram.js +0 -4
- package/dist/src/channels/telegram/TelegramChannel.js +0 -4
- package/dist/src/channels/wabot/WabotDevConnection.js +57 -0
- package/dist/src/channels/{whatsapp/WhatsAppDevSocketContracts.js → wabot/WabotDevSocketContracts.js} +3 -3
- package/dist/src/channels/whatsapp/@whatsapp.js +0 -4
- package/dist/src/channels/whatsapp/EnvWhatsAppRepository.js +49 -0
- package/dist/src/channels/whatsapp/PgWhatsAppRepository.js +41 -0
- package/dist/src/channels/whatsapp/WhatsApp.js +32 -0
- package/dist/src/channels/whatsapp/WhatsAppChannel.js +33 -32
- package/dist/src/channels/whatsapp/{WhatsAppConnection.js → WhatsAppReceiver.js} +4 -6
- package/dist/src/channels/whatsapp/WhatsAppReceiverByDevConnection.js +32 -0
- package/dist/src/channels/whatsapp/WhatsAppReceiverByWebHook.js +63 -0
- package/dist/src/channels/whatsapp/WhatsAppRepository.js +10 -0
- package/dist/src/channels/whatsapp/WhatsAppSender.js +76 -17
- package/dist/src/channels/whatsapp/WhatsAppSenderByCloudApi.js +124 -0
- package/dist/src/channels/whatsapp/WhatsAppSenderByDevConnection.js +61 -0
- package/dist/src/chatbot/ChatBotAdapter.js +1 -5
- package/dist/src/chatbot/metadata/@chatBot.js +0 -5
- package/dist/src/chatbot/metadata/ChatBotMetadataStore.js +0 -5
- package/dist/src/controller/metadata/ControllerMetadataStore.js +0 -2
- package/dist/src/controller/metadata/controller/@chatController.js +0 -2
- package/dist/src/core/IMessageContext.js +0 -2
- package/dist/src/env/WabotEnv.js +6 -0
- package/dist/src/index.d.ts +270 -202
- package/dist/src/index.js +28 -27
- package/dist/src/mindset/MindsetOperator.js +0 -2
- package/dist/src/mindset/metadata/MindsetMetadataStore.js +0 -2
- package/dist/src/mindset/metadata/mindsets/@mindset.js +0 -2
- package/dist/src/mindset/metadata/modules/@mindsetModule.js +0 -2
- package/dist/src/pre-made/module/authentication/requests/SendOneTimePasswordRequest.js +0 -2
- package/dist/src/pre-made/module/authentication/requests/ValidateOneTimePasswordRequest.js +0 -2
- package/dist/src/pre-made/module/register-user/requests/RegisterUserWithEmailRequest.js +0 -2
- package/dist/src/pre-made/repository/chat/pg/PgChatMemory.js +1 -7
- package/dist/src/pre-made/repository/chat/pg/PgChatRepository.js +0 -5
- package/dist/src/pre-made/repository/user/pg/PgUserRepository.js +0 -5
- package/dist/src/repository/pg/PgCrudRepository.js +0 -1
- package/dist/src/server/prepareChatContainer.js +4 -4
- package/dist/src/server/runChannel.js +2 -10
- package/dist/src/server/runServer.js +0 -43
- package/package.json +2 -4
- package/dist/src/channels/whatsapp/WhatsAppDevConnection.js +0 -69
- package/dist/src/channels/whatsapp/WhatsAppProdConnection.js +0 -39
- package/dist/src/controller/express/Express.js +0 -5
- package/dist/src/controller/socket.io/SocketIO.js +0 -5
- package/dist/src/pre-made/repository/chat/sqlite/SqliteChatMemory.js +0 -23
- package/dist/src/pre-made/repository/chat/sqlite/SqliteChatRepository.js +0 -30
- package/dist/src/pre-made/repository/user/sqlite/SqliteUserRepository.js +0 -23
- package/dist/src/repository/sqlite/SqliteCrudRepository.js +0 -85
- package/dist/src/repository/sqlite/SqlitePersistentMapper.js +0 -17
- /package/dist/src/channels/{socket-io → socket}/SocketChannelConfig.js +0 -0
package/dist/src/index.d.ts
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import InjectionToken from 'tsyringe/dist/typings/providers/injection-token';
|
|
2
2
|
import DependencyContainer, { PreResolutionInterceptorCallback, PostResolutionInterceptorCallback } from 'tsyringe/dist/typings/types/dependency-container';
|
|
3
3
|
import InterceptionOptions from 'tsyringe/dist/typings/types/interceptor-options';
|
|
4
|
+
import { Server } from 'http';
|
|
4
5
|
import { Express } from 'express';
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
|
|
6
|
+
import { Server as Server$1 } from 'socket.io';
|
|
7
|
+
import { Socket } from 'socket.io-client';
|
|
8
|
+
import { Pool } from 'pg';
|
|
8
9
|
import * as tsyringe from 'tsyringe';
|
|
9
10
|
import { DependencyContainer as DependencyContainer$1 } from 'tsyringe';
|
|
10
11
|
export { DependencyContainer } from 'tsyringe';
|
|
11
|
-
import { Pool } from 'pg';
|
|
12
|
-
import { Database } from 'sqlite';
|
|
13
|
-
import sqlite3 from 'sqlite3';
|
|
14
12
|
|
|
15
13
|
interface IMindsetFunctionConfig {
|
|
16
14
|
description: string;
|
|
@@ -28,12 +26,12 @@ interface IMindsetFunctionDecoration {
|
|
|
28
26
|
decorationConfig: any;
|
|
29
27
|
}
|
|
30
28
|
|
|
31
|
-
interface
|
|
29
|
+
interface IPersistentData {
|
|
32
30
|
id?: string;
|
|
33
31
|
createdAt?: number | null;
|
|
34
32
|
discardedAt?: number | null;
|
|
35
33
|
}
|
|
36
|
-
declare class Persistent<D extends
|
|
34
|
+
declare class Persistent<D extends IPersistentData = IPersistentData> {
|
|
37
35
|
protected data: D;
|
|
38
36
|
constructor(data: D);
|
|
39
37
|
getId(): string;
|
|
@@ -50,7 +48,7 @@ interface IChatConnection {
|
|
|
50
48
|
channelName: string;
|
|
51
49
|
id: string;
|
|
52
50
|
}
|
|
53
|
-
interface IChatData extends
|
|
51
|
+
interface IChatData extends IPersistentData {
|
|
54
52
|
type: IChatType;
|
|
55
53
|
connections: IChatConnection[];
|
|
56
54
|
}
|
|
@@ -74,7 +72,7 @@ interface IUserConnection {
|
|
|
74
72
|
channelName: string;
|
|
75
73
|
id: string;
|
|
76
74
|
}
|
|
77
|
-
interface IUserData extends
|
|
75
|
+
interface IUserData extends IPersistentData {
|
|
78
76
|
shortName: string;
|
|
79
77
|
connections: IUserConnection[];
|
|
80
78
|
keyValueData: {
|
|
@@ -369,19 +367,19 @@ declare class ChatBot implements IChatBot {
|
|
|
369
367
|
protected processLoop(callback: (message: IChatMessage) => void): Promise<void>;
|
|
370
368
|
}
|
|
371
369
|
|
|
372
|
-
declare class
|
|
373
|
-
private
|
|
370
|
+
declare class DeepSeekChatBotAdapter extends ChatBotAdapter {
|
|
371
|
+
private deepSeek;
|
|
374
372
|
private model;
|
|
375
373
|
constructor(mindset: MindsetOperator);
|
|
374
|
+
validateEnvVariables(envVariables: (string | undefined)[]): void;
|
|
376
375
|
generateNextChatItem(chatItems: ChatItem[]): Promise<ChatItem>;
|
|
377
376
|
private mapChatItems;
|
|
378
377
|
}
|
|
379
378
|
|
|
380
|
-
declare class
|
|
381
|
-
private
|
|
379
|
+
declare class OpenaiChatBotAdapter extends ChatBotAdapter {
|
|
380
|
+
private openai;
|
|
382
381
|
private model;
|
|
383
382
|
constructor(mindset: MindsetOperator);
|
|
384
|
-
validateEnvVariables(envVariables: (string | undefined)[]): void;
|
|
385
383
|
generateNextChatItem(chatItems: ChatItem[]): Promise<ChatItem>;
|
|
386
384
|
private mapChatItems;
|
|
387
385
|
}
|
|
@@ -437,10 +435,6 @@ declare class ControllerMetadataStore {
|
|
|
437
435
|
} | null;
|
|
438
436
|
}
|
|
439
437
|
|
|
440
|
-
declare const ExpressApp: unique symbol;
|
|
441
|
-
|
|
442
|
-
declare const SocketIoApp: unique symbol;
|
|
443
|
-
|
|
444
438
|
declare class CmdChannel implements IChatChannel {
|
|
445
439
|
private chatResolver;
|
|
446
440
|
private userResolver;
|
|
@@ -451,6 +445,63 @@ declare class CmdChannel implements IChatChannel {
|
|
|
451
445
|
connect(): void;
|
|
452
446
|
}
|
|
453
447
|
|
|
448
|
+
declare class HttpServerProvider {
|
|
449
|
+
server: Server | null;
|
|
450
|
+
private listening;
|
|
451
|
+
private logger;
|
|
452
|
+
getHttpServer(): Server;
|
|
453
|
+
listen(): void;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
declare class ExpressProvider {
|
|
457
|
+
private httpServerProvider;
|
|
458
|
+
private expressApp;
|
|
459
|
+
private logger;
|
|
460
|
+
constructor(httpServerProvider: HttpServerProvider);
|
|
461
|
+
getExpress(): Express;
|
|
462
|
+
listen(): void;
|
|
463
|
+
private createExpress;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
interface ISocketChannelConfig {
|
|
467
|
+
channel: string;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
declare class SocketChannelConfig implements ISocketChannelConfig {
|
|
471
|
+
channel: string;
|
|
472
|
+
constructor(channel: string);
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
declare function socket(config: SocketChannelConfig): (target: object, propertyKey: string | symbol) => void;
|
|
476
|
+
|
|
477
|
+
declare class SocketServerProvider {
|
|
478
|
+
private httpServerProvider;
|
|
479
|
+
private socketServer;
|
|
480
|
+
private logger;
|
|
481
|
+
constructor(httpServerProvider: HttpServerProvider);
|
|
482
|
+
getSocketServer(): Server$1;
|
|
483
|
+
listen(): void;
|
|
484
|
+
private createSocketServer;
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
interface ISocketChannelReceivedMessage {
|
|
488
|
+
chatId: string;
|
|
489
|
+
userId: string;
|
|
490
|
+
senderName: string;
|
|
491
|
+
text: string;
|
|
492
|
+
}
|
|
493
|
+
declare class SocketChannel implements IChatChannel {
|
|
494
|
+
private config;
|
|
495
|
+
private socketServerProvider;
|
|
496
|
+
private chatResolver;
|
|
497
|
+
private userResolver;
|
|
498
|
+
private callBack;
|
|
499
|
+
private server;
|
|
500
|
+
constructor(config: SocketChannelConfig, socketServerProvider: SocketServerProvider, chatResolver: ChatResolver, userResolver: UserResolver);
|
|
501
|
+
listen(callback: (message: IReceivedMessage) => void): void;
|
|
502
|
+
connect(): void;
|
|
503
|
+
}
|
|
504
|
+
|
|
454
505
|
interface ITelegramChannelConfig {
|
|
455
506
|
botToken: string;
|
|
456
507
|
}
|
|
@@ -504,14 +555,6 @@ interface IWhatsAppTemplateMessage {
|
|
|
504
555
|
parameters: IWhatsAppTemplateParameter[];
|
|
505
556
|
}
|
|
506
557
|
|
|
507
|
-
type IWhatsAppMessageListener = (message: IConnectionChatMessage) => Promise<void>;
|
|
508
|
-
interface IWhatsAppConnection {
|
|
509
|
-
listenMessage(businessNumber: string, listener: IWhatsAppMessageListener): void;
|
|
510
|
-
sendWhatsApp(businessNumber: string, to: string, message: IChatMessage): Promise<void>;
|
|
511
|
-
sendWhatsAppTemplate(businessNumber: string, to: string, templateMessage: IWhatsAppTemplateMessage): Promise<void>;
|
|
512
|
-
connect(): void;
|
|
513
|
-
}
|
|
514
|
-
|
|
515
558
|
interface IWhatsAppWebhookPayload {
|
|
516
559
|
object: 'whatsapp_business_account';
|
|
517
560
|
entry: IEntry[];
|
|
@@ -564,12 +607,30 @@ interface IAudioMessage extends IBaseMessage {
|
|
|
564
607
|
};
|
|
565
608
|
}
|
|
566
609
|
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
610
|
+
interface IWhatsAppBusinessNumber {
|
|
611
|
+
id: string;
|
|
612
|
+
number: string;
|
|
613
|
+
}
|
|
614
|
+
interface IWhatsAppBusinessAccount {
|
|
615
|
+
id: string;
|
|
616
|
+
}
|
|
617
|
+
interface IWhatsAppData extends IPersistentData {
|
|
618
|
+
slug: string;
|
|
619
|
+
verifyToken: string;
|
|
620
|
+
appSecret: string;
|
|
621
|
+
accessToken: string;
|
|
622
|
+
businessAccount: IWhatsAppBusinessAccount;
|
|
623
|
+
businessNumbers: IWhatsAppBusinessNumber[];
|
|
624
|
+
}
|
|
625
|
+
declare class WhatsApp extends Persistent<IWhatsAppData> {
|
|
626
|
+
getVerifyToken(): string;
|
|
627
|
+
getSlug(): string;
|
|
628
|
+
getBusinessAccount(): IWhatsAppBusinessAccount;
|
|
629
|
+
getAppSecret(): string;
|
|
630
|
+
getBusinessNumbers(): IWhatsAppBusinessNumber[];
|
|
631
|
+
getAccessToken(): string;
|
|
632
|
+
hasBusinessNumber(number: string): boolean;
|
|
633
|
+
getBussinessNumber(number: string): IWhatsAppBusinessNumber | null;
|
|
573
634
|
}
|
|
574
635
|
|
|
575
636
|
declare class Logger {
|
|
@@ -584,100 +645,212 @@ declare class Logger {
|
|
|
584
645
|
private log;
|
|
585
646
|
}
|
|
586
647
|
|
|
587
|
-
|
|
648
|
+
type IWhatsAppMessageListener = (message: IConnectionChatMessage) => Promise<void>;
|
|
649
|
+
interface IListenWhatsAppMessageRequest {
|
|
650
|
+
to: string;
|
|
651
|
+
listener: IWhatsAppMessageListener;
|
|
652
|
+
}
|
|
653
|
+
declare abstract class WhatsAppReceiver {
|
|
588
654
|
protected logger: Logger;
|
|
589
655
|
private listeners;
|
|
590
656
|
constructor(logger: Logger);
|
|
591
|
-
abstract
|
|
592
|
-
|
|
593
|
-
abstract sendWhatsAppTemplate(businessNumber: string, to: string, templateMessage: IWhatsAppTemplateMessage): Promise<void>;
|
|
594
|
-
listenMessage(businessNumber: string, listener: IWhatsAppMessageListener): void;
|
|
657
|
+
abstract connect(): Promise<void>;
|
|
658
|
+
listenMessage(request: IListenWhatsAppMessageRequest): void;
|
|
595
659
|
protected handlePayload(payload: IWhatsAppWebhookPayload): Promise<void>;
|
|
596
660
|
private emmitMessage;
|
|
597
661
|
}
|
|
598
662
|
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
private devToken?;
|
|
603
|
-
private connected;
|
|
604
|
-
constructor();
|
|
605
|
-
sendWhatsApp(businessNumber: string, to: string, chatMessage: IChatMessage): Promise<void>;
|
|
606
|
-
sendWhatsAppTemplate(businessNumber: string, to: string, templateMessage: IWhatsAppTemplateMessage): Promise<void>;
|
|
607
|
-
connect(): void;
|
|
663
|
+
interface IWhatsAppRepository {
|
|
664
|
+
findBySlug(slug: string): Promise<WhatsApp | null>;
|
|
665
|
+
findByBusinessNumber(number: string): Promise<WhatsApp | null>;
|
|
608
666
|
}
|
|
609
667
|
|
|
610
|
-
declare class
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
668
|
+
declare class WhatsAppRepository implements IWhatsAppRepository {
|
|
669
|
+
findBySlug(slug: string): Promise<WhatsApp | null>;
|
|
670
|
+
findByBusinessNumber(number: string): Promise<WhatsApp | null>;
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
interface IWhatsAppTemplate {
|
|
674
|
+
name: string;
|
|
675
|
+
parameter_format: 'POSITIONAL' | 'OTHER';
|
|
676
|
+
components: IWhatsAppTemplateComponent[];
|
|
677
|
+
language: string;
|
|
678
|
+
status: string;
|
|
679
|
+
category: string;
|
|
680
|
+
id: string;
|
|
681
|
+
}
|
|
682
|
+
interface IWhatsAppTemplateComponent {
|
|
683
|
+
type: 'HEADER' | 'BODY' | 'FOOTER';
|
|
684
|
+
format?: 'TEXT';
|
|
685
|
+
text?: string;
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
interface ISendWhatsAppRequest {
|
|
689
|
+
from: string;
|
|
690
|
+
to: string;
|
|
691
|
+
message: IChatMessage;
|
|
692
|
+
}
|
|
693
|
+
interface ISendWhatsAppTemplateRequest {
|
|
694
|
+
from: string;
|
|
695
|
+
to: string;
|
|
696
|
+
templateMessage: IWhatsAppTemplateMessage;
|
|
697
|
+
senderName: string;
|
|
698
|
+
}
|
|
699
|
+
interface IGetWhatsAppTemplateRequest {
|
|
700
|
+
from: string;
|
|
701
|
+
templateName: string;
|
|
702
|
+
languageCode: string;
|
|
703
|
+
}
|
|
704
|
+
interface IWhatsAppSenderOptions {
|
|
705
|
+
writeChatMemory?: boolean;
|
|
706
|
+
}
|
|
707
|
+
declare abstract class WhatsAppSender {
|
|
708
|
+
protected logger: Logger;
|
|
709
|
+
protected chatRepository: ChatRepository;
|
|
710
|
+
protected chatResolver: ChatResolver;
|
|
711
|
+
protected whatsAppRepository: WhatsAppRepository;
|
|
712
|
+
constructor(logger: Logger, chatRepository: ChatRepository, chatResolver: ChatResolver, whatsAppRepository: WhatsAppRepository);
|
|
713
|
+
protected abstract handleSendRequest(request: ISendWhatsAppRequest): Promise<void>;
|
|
714
|
+
protected abstract handleSendTemplateRequest(request: ISendWhatsAppTemplateRequest): Promise<void>;
|
|
715
|
+
protected abstract handleGetWhatsAppTemplate(request: IGetWhatsAppTemplateRequest): Promise<IWhatsAppTemplate | null>;
|
|
716
|
+
sendWhatsApp(request: ISendWhatsAppRequest, options?: IWhatsAppSenderOptions): Promise<void>;
|
|
717
|
+
sendWhatsAppTemplate(request: ISendWhatsAppTemplateRequest, options?: IWhatsAppSenderOptions): Promise<void>;
|
|
718
|
+
getWhatsAppTemplate(request: IGetWhatsAppTemplateRequest): Promise<IWhatsAppTemplate | null>;
|
|
719
|
+
protected resolveTemplateToChatMessage(request: ISendWhatsAppTemplateRequest): Promise<IChatMessage>;
|
|
720
|
+
protected writePrivateChatMemory(message: IChatMessage, to: string): Promise<void>;
|
|
617
721
|
}
|
|
618
722
|
|
|
619
723
|
declare class WhatsAppChannel implements IChatChannel {
|
|
620
724
|
private config;
|
|
621
725
|
private chatResolver;
|
|
622
726
|
private userResolver;
|
|
623
|
-
private
|
|
727
|
+
private sender;
|
|
728
|
+
private receiver;
|
|
624
729
|
private logger;
|
|
625
|
-
|
|
626
|
-
constructor(config: WhatsappChannelConfig, chatResolver: ChatResolver, userResolver: UserResolver, wabotEnv: WabotEnv, devConnection: WhatsAppDevConnection, prodConnection: WhatsAppProdConnection);
|
|
730
|
+
constructor(config: WhatsappChannelConfig, chatResolver: ChatResolver, userResolver: UserResolver, sender: WhatsAppSender, receiver: WhatsAppReceiver);
|
|
627
731
|
listen(callback: (message: IReceivedMessage) => void): void;
|
|
628
732
|
connect(): void;
|
|
629
733
|
}
|
|
630
734
|
|
|
631
|
-
declare
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
interface IDevConnectionRequest {
|
|
640
|
-
token: string;
|
|
735
|
+
declare class WabotDevConnection {
|
|
736
|
+
private devProxy;
|
|
737
|
+
private devProxySocket;
|
|
738
|
+
private devToken;
|
|
739
|
+
private logger;
|
|
740
|
+
static isTokenAvailable(): boolean;
|
|
741
|
+
constructor();
|
|
742
|
+
getSocket(): Promise<Socket>;
|
|
641
743
|
}
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
744
|
+
|
|
745
|
+
declare class WhatsAppReceiverByDevConnection extends WhatsAppReceiver {
|
|
746
|
+
private wabotDevConnection;
|
|
747
|
+
constructor(wabotDevConnection: WabotDevConnection);
|
|
748
|
+
connect(): Promise<void>;
|
|
646
749
|
}
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
750
|
+
|
|
751
|
+
declare class WhatsAppReceiverByWebHook extends WhatsAppReceiver {
|
|
752
|
+
private expressProvider;
|
|
753
|
+
private whatsAppRepository;
|
|
754
|
+
private expressApp;
|
|
755
|
+
private webhookPath;
|
|
756
|
+
constructor(expressProvider: ExpressProvider, whatsAppRepository: WhatsAppRepository);
|
|
757
|
+
connect(): Promise<void>;
|
|
651
758
|
}
|
|
652
759
|
|
|
653
|
-
declare class WhatsAppSender {
|
|
654
|
-
private
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
760
|
+
declare class WhatsAppSenderByDevConnection extends WhatsAppSender {
|
|
761
|
+
private wabotDevConnection;
|
|
762
|
+
constructor(wabotDevConnection: WabotDevConnection, chatRepository: ChatRepository, chatResolver: ChatResolver, whatsAppRepository: WhatsAppRepository);
|
|
763
|
+
handleSendRequest(request: ISendWhatsAppRequest): Promise<void>;
|
|
764
|
+
handleSendTemplateRequest(request: ISendWhatsAppTemplateRequest): Promise<void>;
|
|
765
|
+
handleGetWhatsAppTemplate(request: IGetWhatsAppTemplateRequest): Promise<IWhatsAppTemplate | null>;
|
|
659
766
|
}
|
|
660
767
|
|
|
661
|
-
|
|
662
|
-
|
|
768
|
+
declare class WhatsAppSenderByCloudApi extends WhatsAppSender {
|
|
769
|
+
constructor(chatRepository: ChatRepository, chatResolver: ChatResolver, whatsAppRepository: WhatsAppRepository);
|
|
770
|
+
handleSendRequest(request: ISendWhatsAppRequest): Promise<void>;
|
|
771
|
+
handleSendTemplateRequest(request: ISendWhatsAppTemplateRequest): Promise<void>;
|
|
772
|
+
handleGetWhatsAppTemplate(request: IGetWhatsAppTemplateRequest): Promise<IWhatsAppTemplate | null>;
|
|
663
773
|
}
|
|
664
774
|
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
775
|
+
interface ICrudRepository<T> {
|
|
776
|
+
find(id: string): Promise<T | null>;
|
|
777
|
+
findAll(id: string): Promise<T[]>;
|
|
778
|
+
create(item: T): Promise<void>;
|
|
779
|
+
update(item: T): Promise<void>;
|
|
780
|
+
discard(item: T): Promise<void>;
|
|
668
781
|
}
|
|
669
782
|
|
|
670
|
-
|
|
783
|
+
type IPgRepositoryConfig<P extends Persistent> = {
|
|
784
|
+
schema?: string;
|
|
785
|
+
table: string;
|
|
786
|
+
constructor: IConstructor<P>;
|
|
787
|
+
add?: {
|
|
788
|
+
columns: {
|
|
789
|
+
[column: string]: {
|
|
790
|
+
type: string;
|
|
791
|
+
value: (item: P) => boolean | number | string | null | Date;
|
|
792
|
+
};
|
|
793
|
+
};
|
|
794
|
+
};
|
|
795
|
+
};
|
|
671
796
|
|
|
672
|
-
declare class
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
private
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
797
|
+
declare class PgRepositoryBase<P extends Persistent> {
|
|
798
|
+
protected pool: Pool;
|
|
799
|
+
protected config: IPgRepositoryConfig<any>;
|
|
800
|
+
private tableIsCreated;
|
|
801
|
+
schema: string;
|
|
802
|
+
table: string;
|
|
803
|
+
columnsList: string[];
|
|
804
|
+
columnsAndTypes: string;
|
|
805
|
+
columns: string;
|
|
806
|
+
vars: string;
|
|
807
|
+
updates: string;
|
|
808
|
+
addColumns: {
|
|
809
|
+
[columns: string]: {
|
|
810
|
+
type: string;
|
|
811
|
+
value: (item: P) => number | boolean | string | null | Date;
|
|
812
|
+
};
|
|
813
|
+
};
|
|
814
|
+
constructor(pool: Pool, config: IPgRepositoryConfig<any>);
|
|
815
|
+
values(item: P): (string | number | boolean | Date | null)[];
|
|
816
|
+
protected exec(sql: string, values: any[]): Promise<void>;
|
|
817
|
+
protected query(sql: string, values: any[]): Promise<any[]>;
|
|
818
|
+
protected connect(): Promise<Pool>;
|
|
819
|
+
protected ensureTable(): Promise<void>;
|
|
820
|
+
protected ensureColumns(): Promise<void>;
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
declare class PgCrudRepository<P extends Persistent> extends PgRepositoryBase<P> implements ICrudRepository<P> {
|
|
824
|
+
protected readonly config: IPgRepositoryConfig<P>;
|
|
825
|
+
constructor(pool: Pool, config: IPgRepositoryConfig<P>);
|
|
826
|
+
find(id: string): Promise<P | null>;
|
|
827
|
+
findAll(): Promise<P[]>;
|
|
828
|
+
create(item: P): Promise<void>;
|
|
829
|
+
update(item: P): Promise<void>;
|
|
830
|
+
discard(item: P): Promise<void>;
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
declare class PgWhatsAppRepository extends PgCrudRepository<WhatsApp> implements IWhatsAppRepository {
|
|
834
|
+
constructor(pool: Pool);
|
|
835
|
+
findBySlug(slug: string): Promise<WhatsApp | null>;
|
|
836
|
+
findByBusinessNumber(number: string): Promise<WhatsApp | null>;
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
type IWabotEnvType = 'development' | 'staging' | 'testing' | 'production';
|
|
840
|
+
declare class WabotEnv {
|
|
841
|
+
private envType;
|
|
842
|
+
constructor();
|
|
843
|
+
isDevelopment(): boolean;
|
|
844
|
+
isProduction(): boolean;
|
|
845
|
+
requireString(varName: string): string;
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
declare class EnvWhatsAppRepository implements IWhatsAppRepository {
|
|
849
|
+
private env;
|
|
850
|
+
constructor(env: WabotEnv);
|
|
851
|
+
findBySlug(slug: string): Promise<WhatsApp | null>;
|
|
852
|
+
findByBusinessNumber(number: string): Promise<WhatsApp | null>;
|
|
853
|
+
private getFromEnvVars;
|
|
681
854
|
}
|
|
682
855
|
|
|
683
856
|
declare function prepareChatContainer(container: DependencyContainer$1, context: IMessageContext, mindsetCtor?: IConstructor<IMindset>): Promise<DependencyContainer$1>;
|
|
@@ -756,92 +929,6 @@ declare class RegisterUserModule {
|
|
|
756
929
|
registerUserWithEmail(request: RegisterUserWithEmailRequest): Promise<string>;
|
|
757
930
|
}
|
|
758
931
|
|
|
759
|
-
interface ICrudRepository<T> {
|
|
760
|
-
find(id: string): Promise<T | null>;
|
|
761
|
-
findAll(id: string): Promise<T[]>;
|
|
762
|
-
create(item: T): Promise<void>;
|
|
763
|
-
update(item: T): Promise<void>;
|
|
764
|
-
discard(item: T): Promise<void>;
|
|
765
|
-
}
|
|
766
|
-
|
|
767
|
-
type IPgRepositoryConfig<P extends Persistent> = {
|
|
768
|
-
schema?: string;
|
|
769
|
-
table: string;
|
|
770
|
-
constructor: IConstructor<P>;
|
|
771
|
-
add?: {
|
|
772
|
-
columns: {
|
|
773
|
-
[column: string]: {
|
|
774
|
-
type: string;
|
|
775
|
-
value: (item: P) => boolean | number | string | null | Date;
|
|
776
|
-
};
|
|
777
|
-
};
|
|
778
|
-
};
|
|
779
|
-
};
|
|
780
|
-
|
|
781
|
-
declare class PgRepositoryBase<P extends Persistent> {
|
|
782
|
-
protected pool: Pool;
|
|
783
|
-
protected config: IPgRepositoryConfig<any>;
|
|
784
|
-
private tableIsCreated;
|
|
785
|
-
schema: string;
|
|
786
|
-
table: string;
|
|
787
|
-
columnsList: string[];
|
|
788
|
-
columnsAndTypes: string;
|
|
789
|
-
columns: string;
|
|
790
|
-
vars: string;
|
|
791
|
-
updates: string;
|
|
792
|
-
addColumns: {
|
|
793
|
-
[columns: string]: {
|
|
794
|
-
type: string;
|
|
795
|
-
value: (item: P) => number | boolean | string | null | Date;
|
|
796
|
-
};
|
|
797
|
-
};
|
|
798
|
-
constructor(pool: Pool, config: IPgRepositoryConfig<any>);
|
|
799
|
-
values(item: P): (string | number | boolean | Date | null)[];
|
|
800
|
-
protected exec(sql: string, values: any[]): Promise<void>;
|
|
801
|
-
protected query(sql: string, values: any[]): Promise<any[]>;
|
|
802
|
-
protected connect(): Promise<Pool>;
|
|
803
|
-
protected ensureTable(): Promise<void>;
|
|
804
|
-
protected ensureColumns(): Promise<void>;
|
|
805
|
-
}
|
|
806
|
-
|
|
807
|
-
declare class PgCrudRepository<P extends Persistent> extends PgRepositoryBase<P> implements ICrudRepository<P> {
|
|
808
|
-
protected readonly config: IPgRepositoryConfig<P>;
|
|
809
|
-
constructor(pool: Pool, config: IPgRepositoryConfig<P>);
|
|
810
|
-
find(id: string): Promise<P | null>;
|
|
811
|
-
findAll(): Promise<P[]>;
|
|
812
|
-
create(item: P): Promise<void>;
|
|
813
|
-
update(item: P): Promise<void>;
|
|
814
|
-
discard(item: P): Promise<void>;
|
|
815
|
-
}
|
|
816
|
-
|
|
817
|
-
interface ISqliteRecord {
|
|
818
|
-
id: string;
|
|
819
|
-
data: string;
|
|
820
|
-
}
|
|
821
|
-
|
|
822
|
-
declare class SqliteCrudRepository<P extends Persistent> implements ICrudRepository<P> {
|
|
823
|
-
private table;
|
|
824
|
-
private dbPath;
|
|
825
|
-
private mapper;
|
|
826
|
-
private tableCreated;
|
|
827
|
-
constructor(table: string, dbPath: string, mapper: IReversibleMapper<P, string>);
|
|
828
|
-
find(id: string): Promise<P | null>;
|
|
829
|
-
findAll(): Promise<P[]>;
|
|
830
|
-
create(item: P): Promise<void>;
|
|
831
|
-
update(item: P): Promise<void>;
|
|
832
|
-
discard(item: P): Promise<void>;
|
|
833
|
-
protected getDb(): Promise<Database<sqlite3.Database, sqlite3.Statement>>;
|
|
834
|
-
protected createTable(db: Database<sqlite3.Database, sqlite3.Statement>): Promise<void>;
|
|
835
|
-
}
|
|
836
|
-
|
|
837
|
-
declare class SqlitePersistentMapper<P extends Persistent> implements IReversibleMapper<P, string> {
|
|
838
|
-
private ctor;
|
|
839
|
-
constructor(ctor: IConstructor<P>);
|
|
840
|
-
map(input: P): string;
|
|
841
|
-
rev(input: string): P;
|
|
842
|
-
}
|
|
843
|
-
declare function sqliteMapperFor<P extends Persistent>(ctor: IConstructor<P>): SqlitePersistentMapper<P>;
|
|
844
|
-
|
|
845
932
|
declare class PgUserRepository extends PgCrudRepository<User> implements IUserRepository {
|
|
846
933
|
constructor(pool: Pool);
|
|
847
934
|
findByConnection(query: IUserConnection): Promise<User | null>;
|
|
@@ -854,12 +941,6 @@ declare class RamUserRepository implements IUserRepository {
|
|
|
854
941
|
update(chat: User): Promise<void>;
|
|
855
942
|
}
|
|
856
943
|
|
|
857
|
-
declare class SqliteUserRepository extends SqliteCrudRepository<User> implements IUserRepository {
|
|
858
|
-
constructor();
|
|
859
|
-
findByConnection(query: IUserConnection): Promise<User | null>;
|
|
860
|
-
static getDbPath(): string;
|
|
861
|
-
}
|
|
862
|
-
|
|
863
944
|
declare class PgChatRepository extends PgCrudRepository<Chat> implements IChatRepository {
|
|
864
945
|
constructor(pool: Pool);
|
|
865
946
|
findByConnection(query: IChatConnection): Promise<Chat | null>;
|
|
@@ -872,19 +953,6 @@ declare class PgChatMemory extends PgCrudRepository<ChatItem> implements IChatMe
|
|
|
872
953
|
findLastItems(count: number): Promise<ChatItem[]>;
|
|
873
954
|
}
|
|
874
955
|
|
|
875
|
-
declare class SqliteChatMemory extends SqliteCrudRepository<ChatItem> implements IChatMemory {
|
|
876
|
-
constructor(chatId: string);
|
|
877
|
-
findLastItems(count: number): Promise<ChatItem[]>;
|
|
878
|
-
static getDbPath(chatId: string): string;
|
|
879
|
-
}
|
|
880
|
-
|
|
881
|
-
declare class SqliteChatRepository extends SqliteCrudRepository<Chat> implements IChatRepository {
|
|
882
|
-
constructor();
|
|
883
|
-
findByConnection(query: IChatConnection): Promise<Chat | null>;
|
|
884
|
-
findMemory(chatId: string): Promise<IChatMemory | null>;
|
|
885
|
-
static getDbPath(): string;
|
|
886
|
-
}
|
|
887
|
-
|
|
888
956
|
declare class RamChatMemory implements IChatMemory {
|
|
889
957
|
private memory;
|
|
890
958
|
findLastItems(count: number): Promise<ChatItem[]>;
|
|
@@ -901,4 +969,4 @@ declare class RamChatRepository implements IChatRepository {
|
|
|
901
969
|
private getMemory;
|
|
902
970
|
}
|
|
903
971
|
|
|
904
|
-
export { AuthenticationModule, Chat, ChatBot, ChatBotAdapter, ChatBotMetadataStore, ChatItem, ChatMemory, ChatRepository, ChatResolver, CmdChannel, Container, ControllerMetadataStore, DeepSeekChatBotAdapter, EmailService,
|
|
972
|
+
export { AuthenticationModule, Chat, ChatBot, ChatBotAdapter, ChatBotMetadataStore, ChatItem, ChatMemory, ChatRepository, ChatResolver, CmdChannel, Container, ControllerMetadataStore, DeepSeekChatBotAdapter, EmailService, EnvWhatsAppRepository, ExpressProvider, HttpServerProvider, type IChannelMetadata, type IChatBot, type IChatBotAdapter, type IChatBotMetadata, type IChatChannel, type IChatConnection, type IChatControllerMetadata, type IChatData, type IChatFunctionCall, type IChatItemData, type IChatItemType, type IChatMemory, type IChatMessage, type IChatRepository, type IChatType, type IConnectionChatMessage, type IConstructor, type ICrudRepository, type IEmailService, type IGetWhatsAppTemplateRequest, type IListenWhatsAppMessageRequest, type IMessageContext, type IMessageMetadata, type IMindset, type IMindsetDecoration, type IMindsetFunctionConfig, type IMindsetFunctionDecoration, type IMindsetFunctionMetadata, type IMindsetFunctionParamMetadata, type IMindsetIdentity, type IMindsetMetadata, type IMindsetModuleConfig, type IMindsetModuleDecoration, type IMindsetModuleMetadata, type IOtpService, type IParamConfig, type IParamDecoration, type IPersistentData, type IPgRepositoryConfig, type IReceivedMessage, type IReceivedMessageItem, type IReversibleMapper, type ISendEmailRequest, type ISendWhatsAppRequest, type ISendWhatsAppTemplateRequest, type IServerConfig, type IServerProvider, type ISocketChannelConfig, type ISocketChannelReceivedMessage, type ISystemFunctionCallItem, type ISystemMessageItem, type ITelegramChannelConfig, type IUserConnection, type IUserData, type IUserRepository, type IWabotEnvType, type IWhatsAppBusinessAccount, type IWhatsAppBusinessNumber, type IWhatsAppContact, type IWhatsAppData, type IWhatsAppMessage, type IWhatsAppMessageListener, type IWhatsAppRepository, type IWhatsAppSenderOptions, type IWhatsAppTemplateMessage, type IWhatsAppTemplateParameter, type IWhatsAppWebhookPayload, type IWhatsappChannelConfig, type IchatControllerConfig, type IrunChannelProps, Logger, MINDSET_DECORATION_MINDSET, MINDSET_FUNCTION_DECORATION_FUNCTION, MINDSET_MODULE_DECORATION_MODULE, MessageContext, Mindset, MindsetMetadataStore, MindsetOperator, OpenaiChatBotAdapter, OtpService, PARAM_DECORATION_IS_OPTIONAL, PARAM_DECORATION_PARAM, Persistent, PgChatMemory, PgChatRepository, PgCrudRepository, PgRepositoryBase, PgUserRepository, PgWhatsAppRepository, RamChatMemory, RamChatRepository, RamUserRepository, RegisterUserModule, RegisterUserWithEmailRequest, SendOneTimePasswordRequest, SocketChannel, SocketChannelConfig, SocketServerProvider, TelegramChannel, TelegramChannelConfig, User, UserRepository, UserResolver, ValidateOneTimePasswordRequest, WabotEnv, WhatsApp, WhatsAppChannel, WhatsAppReceiver, WhatsAppReceiverByDevConnection, WhatsAppReceiverByWebHook, WhatsAppRepository, WhatsAppSender, WhatsAppSenderByCloudApi, WhatsAppSenderByDevConnection, WhatsappChannelConfig, chatBot, chatController, cmd, container, inject, injectable, isOptional, mindset, mindsetFunction, mindsetModule, param, prepareChatContainer, runChannel, runServer, singleton, socket, telegram, whatsapp };
|