@wabot-dev/framework 0.1.0-beta.1 → 0.1.0-beta.3
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/WhatsApp.js +29 -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 +41 -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/index.d.ts +251 -203
- package/dist/src/index.js +26 -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 { Pool } from 'pg';
|
|
8
|
+
import { Socket } from 'socket.io-client';
|
|
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,29 @@ 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
|
+
getBusinessAccount(): IWhatsAppBusinessAccount;
|
|
628
|
+
getAppSecret(): string;
|
|
629
|
+
getBusinessNumbers(): IWhatsAppBusinessNumber[];
|
|
630
|
+
getAccessToken(): string;
|
|
631
|
+
hasBusinessNumber(number: string): boolean;
|
|
632
|
+
getBussinessNumber(number: string): IWhatsAppBusinessNumber | null;
|
|
573
633
|
}
|
|
574
634
|
|
|
575
635
|
declare class Logger {
|
|
@@ -584,102 +644,187 @@ declare class Logger {
|
|
|
584
644
|
private log;
|
|
585
645
|
}
|
|
586
646
|
|
|
587
|
-
|
|
647
|
+
type IWhatsAppMessageListener = (message: IConnectionChatMessage) => Promise<void>;
|
|
648
|
+
interface IListenWhatsAppMessageRequest {
|
|
649
|
+
to: string;
|
|
650
|
+
listener: IWhatsAppMessageListener;
|
|
651
|
+
}
|
|
652
|
+
declare abstract class WhatsAppReceiver {
|
|
588
653
|
protected logger: Logger;
|
|
589
654
|
private listeners;
|
|
590
655
|
constructor(logger: Logger);
|
|
591
|
-
abstract
|
|
592
|
-
|
|
593
|
-
abstract sendWhatsAppTemplate(businessNumber: string, to: string, templateMessage: IWhatsAppTemplateMessage): Promise<void>;
|
|
594
|
-
listenMessage(businessNumber: string, listener: IWhatsAppMessageListener): void;
|
|
656
|
+
abstract connect(): Promise<void>;
|
|
657
|
+
listenMessage(request: IListenWhatsAppMessageRequest): void;
|
|
595
658
|
protected handlePayload(payload: IWhatsAppWebhookPayload): Promise<void>;
|
|
596
659
|
private emmitMessage;
|
|
597
660
|
}
|
|
598
661
|
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
sendWhatsApp(businessNumber: string, to: string, chatMessage: IChatMessage): Promise<void>;
|
|
606
|
-
sendWhatsAppTemplate(businessNumber: string, to: string, templateMessage: IWhatsAppTemplateMessage): Promise<void>;
|
|
607
|
-
connect(): void;
|
|
662
|
+
interface ICrudRepository<T> {
|
|
663
|
+
find(id: string): Promise<T | null>;
|
|
664
|
+
findAll(id: string): Promise<T[]>;
|
|
665
|
+
create(item: T): Promise<void>;
|
|
666
|
+
update(item: T): Promise<void>;
|
|
667
|
+
discard(item: T): Promise<void>;
|
|
608
668
|
}
|
|
609
669
|
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
670
|
+
type IPgRepositoryConfig<P extends Persistent> = {
|
|
671
|
+
schema?: string;
|
|
672
|
+
table: string;
|
|
673
|
+
constructor: IConstructor<P>;
|
|
674
|
+
add?: {
|
|
675
|
+
columns: {
|
|
676
|
+
[column: string]: {
|
|
677
|
+
type: string;
|
|
678
|
+
value: (item: P) => boolean | number | string | null | Date;
|
|
679
|
+
};
|
|
680
|
+
};
|
|
681
|
+
};
|
|
682
|
+
};
|
|
683
|
+
|
|
684
|
+
declare class PgRepositoryBase<P extends Persistent> {
|
|
685
|
+
protected pool: Pool;
|
|
686
|
+
protected config: IPgRepositoryConfig<any>;
|
|
687
|
+
private tableIsCreated;
|
|
688
|
+
schema: string;
|
|
689
|
+
table: string;
|
|
690
|
+
columnsList: string[];
|
|
691
|
+
columnsAndTypes: string;
|
|
692
|
+
columns: string;
|
|
693
|
+
vars: string;
|
|
694
|
+
updates: string;
|
|
695
|
+
addColumns: {
|
|
696
|
+
[columns: string]: {
|
|
697
|
+
type: string;
|
|
698
|
+
value: (item: P) => number | boolean | string | null | Date;
|
|
699
|
+
};
|
|
700
|
+
};
|
|
701
|
+
constructor(pool: Pool, config: IPgRepositoryConfig<any>);
|
|
702
|
+
values(item: P): (string | number | boolean | Date | null)[];
|
|
703
|
+
protected exec(sql: string, values: any[]): Promise<void>;
|
|
704
|
+
protected query(sql: string, values: any[]): Promise<any[]>;
|
|
705
|
+
protected connect(): Promise<Pool>;
|
|
706
|
+
protected ensureTable(): Promise<void>;
|
|
707
|
+
protected ensureColumns(): Promise<void>;
|
|
617
708
|
}
|
|
618
709
|
|
|
619
|
-
declare class
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
listen(callback: (message: IReceivedMessage) => void): void;
|
|
628
|
-
connect(): void;
|
|
710
|
+
declare class PgCrudRepository<P extends Persistent> extends PgRepositoryBase<P> implements ICrudRepository<P> {
|
|
711
|
+
protected readonly config: IPgRepositoryConfig<P>;
|
|
712
|
+
constructor(pool: Pool, config: IPgRepositoryConfig<P>);
|
|
713
|
+
find(id: string): Promise<P | null>;
|
|
714
|
+
findAll(): Promise<P[]>;
|
|
715
|
+
create(item: P): Promise<void>;
|
|
716
|
+
update(item: P): Promise<void>;
|
|
717
|
+
discard(item: P): Promise<void>;
|
|
629
718
|
}
|
|
630
719
|
|
|
631
|
-
declare
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
readonly DEV_CONNECTION: "dev-connection";
|
|
636
|
-
readonly DEV_SEND_WHATSAPP: "dev-send-whatsapp";
|
|
637
|
-
readonly DEV_SEND_WHATSAPP_TEMPLATE: "dev-send-whatsapp-template";
|
|
638
|
-
};
|
|
639
|
-
interface IDevConnectionRequest {
|
|
640
|
-
token: string;
|
|
720
|
+
declare class WhatsAppRepository extends PgCrudRepository<WhatsApp> {
|
|
721
|
+
constructor(pool: Pool);
|
|
722
|
+
findBySlug(slug: string): Promise<WhatsApp | null>;
|
|
723
|
+
findByBusinessNumber(number: string): Promise<WhatsApp | null>;
|
|
641
724
|
}
|
|
642
|
-
|
|
725
|
+
|
|
726
|
+
interface IWhatsAppTemplate {
|
|
727
|
+
name: string;
|
|
728
|
+
parameter_format: 'POSITIONAL' | 'OTHER';
|
|
729
|
+
components: IWhatsAppTemplateComponent[];
|
|
730
|
+
language: string;
|
|
731
|
+
status: string;
|
|
732
|
+
category: string;
|
|
733
|
+
id: string;
|
|
734
|
+
}
|
|
735
|
+
interface IWhatsAppTemplateComponent {
|
|
736
|
+
type: 'HEADER' | 'BODY' | 'FOOTER';
|
|
737
|
+
format?: 'TEXT';
|
|
738
|
+
text?: string;
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
interface ISendWhatsAppRequest {
|
|
643
742
|
from: string;
|
|
644
743
|
to: string;
|
|
645
744
|
message: IChatMessage;
|
|
646
745
|
}
|
|
647
|
-
interface
|
|
746
|
+
interface ISendWhatsAppTemplateRequest {
|
|
648
747
|
from: string;
|
|
649
748
|
to: string;
|
|
650
|
-
|
|
749
|
+
templateMessage: IWhatsAppTemplateMessage;
|
|
750
|
+
senderName: string;
|
|
651
751
|
}
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
constructor(wabotEnv: WabotEnv, devConnection: WhatsAppDevConnection, prodConnection: WhatsAppProdConnection);
|
|
657
|
-
send(businessNumber: string, to: string, message: IChatMessage): Promise<void>;
|
|
658
|
-
sendTemplate(businessNumber: string, to: string, templateMessage: IWhatsAppTemplateMessage): Promise<void>;
|
|
752
|
+
interface IGetWhatsAppTemplateRequest {
|
|
753
|
+
from: string;
|
|
754
|
+
templateName: string;
|
|
755
|
+
languageCode: string;
|
|
659
756
|
}
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
channel: string;
|
|
757
|
+
interface IWhatsAppSenderOptions {
|
|
758
|
+
writeChatMemory?: boolean;
|
|
663
759
|
}
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
760
|
+
declare abstract class WhatsAppSender {
|
|
761
|
+
protected logger: Logger;
|
|
762
|
+
protected chatRepository: ChatRepository;
|
|
763
|
+
protected chatResolver: ChatResolver;
|
|
764
|
+
protected whatsAppRepository: WhatsAppRepository;
|
|
765
|
+
constructor(logger: Logger, chatRepository: ChatRepository, chatResolver: ChatResolver, whatsAppRepository: WhatsAppRepository);
|
|
766
|
+
protected abstract handleSendRequest(request: ISendWhatsAppRequest): Promise<void>;
|
|
767
|
+
protected abstract handleSendTemplateRequest(request: ISendWhatsAppTemplateRequest): Promise<void>;
|
|
768
|
+
protected abstract handleGetWhatsAppTemplate(request: IGetWhatsAppTemplateRequest): Promise<IWhatsAppTemplate | null>;
|
|
769
|
+
sendWhatsApp(request: ISendWhatsAppRequest, options?: IWhatsAppSenderOptions): Promise<void>;
|
|
770
|
+
sendWhatsAppTemplate(request: ISendWhatsAppTemplateRequest, options?: IWhatsAppSenderOptions): Promise<void>;
|
|
771
|
+
getWhatsAppTemplate(request: IGetWhatsAppTemplateRequest): Promise<IWhatsAppTemplate | null>;
|
|
772
|
+
protected resolveTemplateToChatMessage(request: ISendWhatsAppTemplateRequest): Promise<IChatMessage>;
|
|
773
|
+
protected writePrivateChatMemory(message: IChatMessage, to: string): Promise<void>;
|
|
668
774
|
}
|
|
669
775
|
|
|
670
|
-
declare
|
|
671
|
-
|
|
672
|
-
declare class SocketChannel implements IChatChannel {
|
|
776
|
+
declare class WhatsAppChannel implements IChatChannel {
|
|
673
777
|
private config;
|
|
674
|
-
private server;
|
|
675
778
|
private chatResolver;
|
|
676
779
|
private userResolver;
|
|
677
|
-
private
|
|
678
|
-
|
|
780
|
+
private sender;
|
|
781
|
+
private receiver;
|
|
782
|
+
private logger;
|
|
783
|
+
constructor(config: WhatsappChannelConfig, chatResolver: ChatResolver, userResolver: UserResolver, sender: WhatsAppSender, receiver: WhatsAppReceiver);
|
|
679
784
|
listen(callback: (message: IReceivedMessage) => void): void;
|
|
680
785
|
connect(): void;
|
|
681
786
|
}
|
|
682
787
|
|
|
788
|
+
declare class WabotDevConnection {
|
|
789
|
+
private devProxy;
|
|
790
|
+
private devProxySocket;
|
|
791
|
+
private devToken;
|
|
792
|
+
private logger;
|
|
793
|
+
static isTokenAvailable(): boolean;
|
|
794
|
+
constructor();
|
|
795
|
+
getSocket(): Promise<Socket>;
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
declare class WhatsAppReceiverByDevConnection extends WhatsAppReceiver {
|
|
799
|
+
private wabotDevConnection;
|
|
800
|
+
constructor(wabotDevConnection: WabotDevConnection);
|
|
801
|
+
connect(): Promise<void>;
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
declare class WhatsAppReceiverByWebHook extends WhatsAppReceiver {
|
|
805
|
+
private expressProvider;
|
|
806
|
+
private whatsAppRepository;
|
|
807
|
+
private expressApp;
|
|
808
|
+
private webhookPath;
|
|
809
|
+
constructor(expressProvider: ExpressProvider, whatsAppRepository: WhatsAppRepository);
|
|
810
|
+
connect(): Promise<void>;
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
declare class WhatsAppSenderByDevConnection extends WhatsAppSender {
|
|
814
|
+
private wabotDevConnection;
|
|
815
|
+
constructor(wabotDevConnection: WabotDevConnection, chatRepository: ChatRepository, chatResolver: ChatResolver, whatsAppRepository: WhatsAppRepository);
|
|
816
|
+
handleSendRequest(request: ISendWhatsAppRequest): Promise<void>;
|
|
817
|
+
handleSendTemplateRequest(request: ISendWhatsAppTemplateRequest): Promise<void>;
|
|
818
|
+
handleGetWhatsAppTemplate(request: IGetWhatsAppTemplateRequest): Promise<IWhatsAppTemplate | null>;
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
declare class WhatsAppSenderByCloudApi extends WhatsAppSender {
|
|
822
|
+
constructor(chatRepository: ChatRepository, chatResolver: ChatResolver, whatsAppRepository: WhatsAppRepository);
|
|
823
|
+
handleSendRequest(request: ISendWhatsAppRequest): Promise<void>;
|
|
824
|
+
handleSendTemplateRequest(request: ISendWhatsAppTemplateRequest): Promise<void>;
|
|
825
|
+
handleGetWhatsAppTemplate(request: IGetWhatsAppTemplateRequest): Promise<IWhatsAppTemplate | null>;
|
|
826
|
+
}
|
|
827
|
+
|
|
683
828
|
declare function prepareChatContainer(container: DependencyContainer$1, context: IMessageContext, mindsetCtor?: IConstructor<IMindset>): Promise<DependencyContainer$1>;
|
|
684
829
|
|
|
685
830
|
interface IrunChannelProps {
|
|
@@ -756,92 +901,6 @@ declare class RegisterUserModule {
|
|
|
756
901
|
registerUserWithEmail(request: RegisterUserWithEmailRequest): Promise<string>;
|
|
757
902
|
}
|
|
758
903
|
|
|
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
904
|
declare class PgUserRepository extends PgCrudRepository<User> implements IUserRepository {
|
|
846
905
|
constructor(pool: Pool);
|
|
847
906
|
findByConnection(query: IUserConnection): Promise<User | null>;
|
|
@@ -854,12 +913,6 @@ declare class RamUserRepository implements IUserRepository {
|
|
|
854
913
|
update(chat: User): Promise<void>;
|
|
855
914
|
}
|
|
856
915
|
|
|
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
916
|
declare class PgChatRepository extends PgCrudRepository<Chat> implements IChatRepository {
|
|
864
917
|
constructor(pool: Pool);
|
|
865
918
|
findByConnection(query: IChatConnection): Promise<Chat | null>;
|
|
@@ -872,19 +925,6 @@ declare class PgChatMemory extends PgCrudRepository<ChatItem> implements IChatMe
|
|
|
872
925
|
findLastItems(count: number): Promise<ChatItem[]>;
|
|
873
926
|
}
|
|
874
927
|
|
|
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
928
|
declare class RamChatMemory implements IChatMemory {
|
|
889
929
|
private memory;
|
|
890
930
|
findLastItems(count: number): Promise<ChatItem[]>;
|
|
@@ -901,4 +941,12 @@ declare class RamChatRepository implements IChatRepository {
|
|
|
901
941
|
private getMemory;
|
|
902
942
|
}
|
|
903
943
|
|
|
904
|
-
|
|
944
|
+
type IWabotEnvType = 'development' | 'staging' | 'testing' | 'production';
|
|
945
|
+
declare class WabotEnv {
|
|
946
|
+
private envType;
|
|
947
|
+
constructor();
|
|
948
|
+
isDevelopment(): boolean;
|
|
949
|
+
isProduction(): boolean;
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
export { AuthenticationModule, Chat, ChatBot, ChatBotAdapter, ChatBotMetadataStore, ChatItem, ChatMemory, ChatRepository, ChatResolver, CmdChannel, Container, ControllerMetadataStore, DeepSeekChatBotAdapter, EmailService, 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 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, 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 };
|