@wabot-dev/framework 0.0.17 → 0.0.51

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.
Files changed (88) hide show
  1. package/dist/src/ai/deepseek/DeepSeekChatBotAdapter.js +12 -13
  2. package/dist/src/ai/openia/OpenaiChatBotAdapter.js +9 -7
  3. package/dist/src/channels/cmd/@cmd.js +0 -4
  4. package/dist/src/channels/cmd/CmdChannel.js +0 -4
  5. package/dist/src/channels/express/ExpressProvider.js +46 -0
  6. package/dist/src/channels/http/HttpServerProvider.js +31 -0
  7. package/dist/src/channels/{socket-io → socket}/@socket.js +0 -4
  8. package/dist/src/channels/{socket-io → socket}/SocketChannel.js +12 -11
  9. package/dist/src/channels/socket/SocketServerProvider.js +50 -0
  10. package/dist/src/channels/telegram/@telegram.js +0 -4
  11. package/dist/src/channels/telegram/TelegramChannel.js +0 -4
  12. package/dist/src/channels/wabot/WabotDevConnection.js +57 -0
  13. package/dist/src/channels/{whatsapp/WhatsAppDevSocketContracts.js → wabot/WabotDevSocketContracts.js} +3 -3
  14. package/dist/src/channels/whatsapp/@whatsapp.js +0 -4
  15. package/dist/src/channels/whatsapp/EnvWhatsAppRepository.js +49 -0
  16. package/dist/src/channels/whatsapp/PgWhatsAppRepository.js +41 -0
  17. package/dist/src/channels/whatsapp/WhatsApp.js +32 -0
  18. package/dist/src/channels/whatsapp/WhatsAppChannel.js +33 -32
  19. package/dist/src/channels/whatsapp/{WhatsAppConnection.js → WhatsAppReceiver.js} +4 -6
  20. package/dist/src/channels/whatsapp/WhatsAppReceiverByDevConnection.js +32 -0
  21. package/dist/src/channels/whatsapp/WhatsAppReceiverByWebHook.js +63 -0
  22. package/dist/src/channels/whatsapp/WhatsAppRepository.js +10 -0
  23. package/dist/src/channels/whatsapp/WhatsAppSender.js +93 -17
  24. package/dist/src/channels/whatsapp/WhatsAppSenderByCloudApi.js +124 -0
  25. package/dist/src/channels/whatsapp/WhatsAppSenderByDevConnection.js +61 -0
  26. package/dist/src/chatbot/ChatBotAdapter.js +1 -5
  27. package/dist/src/chatbot/metadata/@chatBot.js +0 -5
  28. package/dist/src/chatbot/metadata/ChatBotMetadataStore.js +0 -5
  29. package/dist/src/controller/metadata/ControllerMetadataStore.js +0 -2
  30. package/dist/src/controller/metadata/controller/@chatController.js +0 -2
  31. package/dist/src/core/IMessageContext.js +0 -2
  32. package/dist/src/env/WabotEnv.js +6 -0
  33. package/dist/src/index.d.ts +421 -201
  34. package/dist/src/index.js +55 -28
  35. package/dist/src/mindset/MindsetOperator.js +1 -3
  36. package/dist/src/mindset/metadata/MindsetMetadataStore.js +0 -2
  37. package/dist/src/mindset/metadata/mindsets/@mindset.js +0 -2
  38. package/dist/src/mindset/metadata/modules/@mindsetModule.js +0 -2
  39. package/dist/src/pre-made/module/authentication/requests/SendOneTimePasswordRequest.js +0 -2
  40. package/dist/src/pre-made/module/authentication/requests/ValidateOneTimePasswordRequest.js +0 -2
  41. package/dist/src/pre-made/module/html/HtmlModule.js +70 -0
  42. package/dist/src/pre-made/module/register-user/requests/RegisterUserWithEmailRequest.js +0 -2
  43. package/dist/src/pre-made/repository/chat/pg/PgChatMemory.js +1 -7
  44. package/dist/src/pre-made/repository/chat/pg/PgChatRepository.js +0 -5
  45. package/dist/src/pre-made/repository/user/pg/PgUserRepository.js +0 -5
  46. package/dist/src/repository/pg/PgCrudRepository.js +7 -1
  47. package/dist/src/rest-controller/metadata/@get.js +19 -0
  48. package/dist/src/rest-controller/metadata/@post.js +19 -0
  49. package/dist/src/rest-controller/metadata/@restController.js +15 -0
  50. package/dist/src/rest-controller/metadata/RestControllerMetadataStore.js +37 -0
  51. package/dist/src/rest-controller/runRestControllers.js +74 -0
  52. package/dist/src/server/prepareChatContainer.js +4 -4
  53. package/dist/src/server/runChannel.js +2 -10
  54. package/dist/src/server/runServer.js +0 -43
  55. package/dist/src/validation/metadata/@isBoolean.js +17 -0
  56. package/dist/src/validation/metadata/@isDate.js +17 -0
  57. package/dist/src/validation/metadata/@isNotEmpty.js +17 -0
  58. package/dist/src/validation/metadata/@isNumber.js +17 -0
  59. package/dist/src/validation/metadata/@isOptional.js +17 -0
  60. package/dist/src/validation/metadata/@isPresent.js +17 -0
  61. package/dist/src/validation/metadata/@isString.js +17 -0
  62. package/dist/src/validation/metadata/@max.js +18 -0
  63. package/dist/src/validation/metadata/@min.js +18 -0
  64. package/dist/src/validation/metadata/@validable.js +14 -0
  65. package/dist/src/validation/metadata/ValidationMetadataStore.js +55 -0
  66. package/dist/src/validation/validateModel2.js +11 -0
  67. package/dist/src/validation/validators/validateIsBoolean.js +12 -0
  68. package/dist/src/validation/validators/validateIsDate.js +16 -0
  69. package/dist/src/validation/validators/validateIsNotEmpty.js +12 -0
  70. package/dist/src/validation/validators/validateIsNumber.js +12 -0
  71. package/dist/src/validation/validators/validateIsOptional.js +5 -0
  72. package/dist/src/validation/validators/validateIsPresent.js +12 -0
  73. package/dist/src/validation/validators/validateIsString.js +12 -0
  74. package/dist/src/validation/validators/validateMax.js +17 -0
  75. package/dist/src/validation/validators/validateMin.js +17 -0
  76. package/dist/src/validation/validators/validateModel.js +47 -0
  77. package/package.json +4 -6
  78. package/dist/src/channels/whatsapp/WhatsAppDevConnection.js +0 -69
  79. package/dist/src/channels/whatsapp/WhatsAppProdConnection.js +0 -39
  80. package/dist/src/controller/express/Express.js +0 -5
  81. package/dist/src/controller/socket.io/SocketIO.js +0 -5
  82. package/dist/src/mindset/metadata/params/@isOptional.js +0 -21
  83. package/dist/src/pre-made/repository/chat/sqlite/SqliteChatMemory.js +0 -23
  84. package/dist/src/pre-made/repository/chat/sqlite/SqliteChatRepository.js +0 -30
  85. package/dist/src/pre-made/repository/user/sqlite/SqliteUserRepository.js +0 -23
  86. package/dist/src/repository/sqlite/SqliteCrudRepository.js +0 -85
  87. package/dist/src/repository/sqlite/SqlitePersistentMapper.js +0 -17
  88. /package/dist/src/channels/{socket-io → socket}/SocketChannelConfig.js +0 -0
@@ -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
- export { Express } from 'express';
6
- import { Server } from 'socket.io';
7
- export { Server as SocketIo } from 'socket.io';
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 IPersistent {
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 IPersistent = IPersistent> {
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 IPersistent {
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 IPersistent {
75
+ interface IUserData extends IPersistentData {
78
76
  shortName: string;
79
77
  connections: IUserConnection[];
80
78
  keyValueData: {
@@ -228,8 +226,6 @@ interface IMindsetModuleDecoration {
228
226
  decorationConfig: any;
229
227
  }
230
228
 
231
- declare function isOptional(): PropertyDecorator;
232
-
233
229
  interface IParamConfig {
234
230
  name?: string;
235
231
  optional?: boolean;
@@ -369,19 +365,20 @@ declare class ChatBot implements IChatBot {
369
365
  protected processLoop(callback: (message: IChatMessage) => void): Promise<void>;
370
366
  }
371
367
 
372
- declare class OpenaiChatBotAdapter extends ChatBotAdapter {
373
- private openai;
368
+ declare class DeepSeekChatBotAdapter extends ChatBotAdapter {
369
+ private deepSeek;
374
370
  private model;
375
371
  constructor(mindset: MindsetOperator);
372
+ validateEnvVariables(envVariables: (string | undefined)[]): void;
376
373
  generateNextChatItem(chatItems: ChatItem[]): Promise<ChatItem>;
377
374
  private mapChatItems;
378
375
  }
379
376
 
380
- declare class DeepSeekChatBotAdapter extends ChatBotAdapter {
381
- private deepSeek;
377
+ declare class OpenaiChatBotAdapter extends ChatBotAdapter {
378
+ private openai;
382
379
  private model;
380
+ private logger;
383
381
  constructor(mindset: MindsetOperator);
384
- validateEnvVariables(envVariables: (string | undefined)[]): void;
385
382
  generateNextChatItem(chatItems: ChatItem[]): Promise<ChatItem>;
386
383
  private mapChatItems;
387
384
  }
@@ -437,10 +434,6 @@ declare class ControllerMetadataStore {
437
434
  } | null;
438
435
  }
439
436
 
440
- declare const ExpressApp: unique symbol;
441
-
442
- declare const SocketIoApp: unique symbol;
443
-
444
437
  declare class CmdChannel implements IChatChannel {
445
438
  private chatResolver;
446
439
  private userResolver;
@@ -451,6 +444,63 @@ declare class CmdChannel implements IChatChannel {
451
444
  connect(): void;
452
445
  }
453
446
 
447
+ declare class HttpServerProvider {
448
+ server: Server | null;
449
+ private listening;
450
+ private logger;
451
+ getHttpServer(): Server;
452
+ listen(): void;
453
+ }
454
+
455
+ declare class ExpressProvider {
456
+ private httpServerProvider;
457
+ private expressApp;
458
+ private logger;
459
+ constructor(httpServerProvider: HttpServerProvider);
460
+ getExpress(): Express;
461
+ listen(): void;
462
+ private createExpress;
463
+ }
464
+
465
+ interface ISocketChannelConfig {
466
+ channel: string;
467
+ }
468
+
469
+ declare class SocketChannelConfig implements ISocketChannelConfig {
470
+ channel: string;
471
+ constructor(channel: string);
472
+ }
473
+
474
+ declare function socket(config: SocketChannelConfig): (target: object, propertyKey: string | symbol) => void;
475
+
476
+ declare class SocketServerProvider {
477
+ private httpServerProvider;
478
+ private socketServer;
479
+ private logger;
480
+ constructor(httpServerProvider: HttpServerProvider);
481
+ getSocketServer(): Server$1;
482
+ listen(): void;
483
+ private createSocketServer;
484
+ }
485
+
486
+ interface ISocketChannelReceivedMessage {
487
+ chatId: string;
488
+ userId: string;
489
+ senderName: string;
490
+ text: string;
491
+ }
492
+ declare class SocketChannel implements IChatChannel {
493
+ private config;
494
+ private socketServerProvider;
495
+ private chatResolver;
496
+ private userResolver;
497
+ private callBack;
498
+ private server;
499
+ constructor(config: SocketChannelConfig, socketServerProvider: SocketServerProvider, chatResolver: ChatResolver, userResolver: UserResolver);
500
+ listen(callback: (message: IReceivedMessage) => void): void;
501
+ connect(): void;
502
+ }
503
+
454
504
  interface ITelegramChannelConfig {
455
505
  botToken: string;
456
506
  }
@@ -485,6 +535,7 @@ declare function whatsapp(config: IWhatsappChannelConfig): (target: object, prop
485
535
  type IWhatsAppTemplateParameter = {
486
536
  type: 'text';
487
537
  text: string;
538
+ parameter_name?: string;
488
539
  } | {
489
540
  type: 'currency';
490
541
  currency: {
@@ -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
- type IWabotEnvType = 'development' | 'staging' | 'testing' | 'production';
568
- declare class WabotEnv {
569
- private envType;
570
- constructor();
571
- isDevelopment(): boolean;
572
- isProduction(): boolean;
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,215 @@ declare class Logger {
584
645
  private log;
585
646
  }
586
647
 
587
- declare abstract class WhatsAppConnection implements IWhatsAppConnection {
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 sendWhatsApp(businessNumber: string, to: string, chatMessage: IChatMessage): Promise<void>;
592
- abstract connect(): void;
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
- declare class WhatsAppDevConnection extends WhatsAppConnection implements IWhatsAppConnection {
600
- private devProxy;
601
- private devProxySocket;
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 WhatsAppProdConnection implements IWhatsAppConnection {
611
- private express;
612
- constructor(express: Express);
613
- listenMessage(businessNumber: string, listener: IWhatsAppMessageListener): void;
614
- sendWhatsApp(businessNumber: string, to: string, replyMessage: IChatMessage): Promise<void>;
615
- sendWhatsAppTemplate(businessNumber: string, to: string, templateMessage: IWhatsAppTemplateMessage): Promise<void>;
616
- connect(): void;
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>;
721
+ private replaceTemplateParameters;
617
722
  }
618
723
 
619
724
  declare class WhatsAppChannel implements IChatChannel {
620
725
  private config;
621
726
  private chatResolver;
622
727
  private userResolver;
623
- private wabotEnv;
728
+ private sender;
729
+ private receiver;
624
730
  private logger;
625
- private whatsAppConection;
626
- constructor(config: WhatsappChannelConfig, chatResolver: ChatResolver, userResolver: UserResolver, wabotEnv: WabotEnv, devConnection: WhatsAppDevConnection, prodConnection: WhatsAppProdConnection);
731
+ constructor(config: WhatsappChannelConfig, chatResolver: ChatResolver, userResolver: UserResolver, sender: WhatsAppSender, receiver: WhatsAppReceiver);
627
732
  listen(callback: (message: IReceivedMessage) => void): void;
628
733
  connect(): void;
629
734
  }
630
735
 
631
- declare const devWhatsAppListentEvent: {
632
- readonly DEV_WATSAPP_WEBHOOK: "dev-whatsapp-webhook";
633
- };
634
- declare const devWhatsappEmitEvent: {
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;
736
+ declare class WabotDevConnection {
737
+ private devProxy;
738
+ private devProxySocket;
739
+ private devToken;
740
+ private logger;
741
+ static isTokenAvailable(): boolean;
742
+ constructor();
743
+ getSocket(): Promise<Socket>;
641
744
  }
642
- interface IDevSendWhatsappRequest {
643
- from: string;
644
- to: string;
645
- message: IChatMessage;
745
+
746
+ declare class WhatsAppReceiverByDevConnection extends WhatsAppReceiver {
747
+ private wabotDevConnection;
748
+ constructor(wabotDevConnection: WabotDevConnection);
749
+ connect(): Promise<void>;
646
750
  }
647
- interface IDevSendWhatsappTemplateRequest {
648
- from: string;
649
- to: string;
650
- message: IWhatsAppTemplateMessage;
751
+
752
+ declare class WhatsAppReceiverByWebHook extends WhatsAppReceiver {
753
+ private expressProvider;
754
+ private whatsAppRepository;
755
+ private expressApp;
756
+ private webhookPath;
757
+ constructor(expressProvider: ExpressProvider, whatsAppRepository: WhatsAppRepository);
758
+ connect(): Promise<void>;
651
759
  }
652
760
 
653
- declare class WhatsAppSender {
654
- private wabotEnv;
655
- private whatsAppConection;
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>;
761
+ declare class WhatsAppSenderByDevConnection extends WhatsAppSender {
762
+ private wabotDevConnection;
763
+ constructor(wabotDevConnection: WabotDevConnection, chatRepository: ChatRepository, chatResolver: ChatResolver, whatsAppRepository: WhatsAppRepository);
764
+ handleSendRequest(request: ISendWhatsAppRequest): Promise<void>;
765
+ handleSendTemplateRequest(request: ISendWhatsAppTemplateRequest): Promise<void>;
766
+ handleGetWhatsAppTemplate(request: IGetWhatsAppTemplateRequest): Promise<IWhatsAppTemplate | null>;
659
767
  }
660
768
 
661
- interface ISocketChannelConfig {
662
- channel: string;
769
+ declare class WhatsAppSenderByCloudApi extends WhatsAppSender {
770
+ constructor(chatRepository: ChatRepository, chatResolver: ChatResolver, whatsAppRepository: WhatsAppRepository);
771
+ handleSendRequest(request: ISendWhatsAppRequest): Promise<void>;
772
+ handleSendTemplateRequest(request: ISendWhatsAppTemplateRequest): Promise<void>;
773
+ handleGetWhatsAppTemplate(request: IGetWhatsAppTemplateRequest): Promise<IWhatsAppTemplate | null>;
663
774
  }
664
775
 
665
- declare class SocketChannelConfig implements ISocketChannelConfig {
666
- channel: string;
667
- constructor(channel: string);
776
+ interface ICrudRepository<T> {
777
+ find(id: string): Promise<T | null>;
778
+ findOrThrow(id: string): Promise<T>;
779
+ findAll(id: string): Promise<T[]>;
780
+ create(item: T): Promise<void>;
781
+ update(item: T): Promise<void>;
782
+ discard(item: T): Promise<void>;
668
783
  }
669
784
 
670
- declare function socket(config: SocketChannelConfig): (target: object, propertyKey: string | symbol) => void;
785
+ type IPgRepositoryConfig<P extends Persistent> = {
786
+ schema?: string;
787
+ table: string;
788
+ constructor: IConstructor<P>;
789
+ add?: {
790
+ columns: {
791
+ [column: string]: {
792
+ type: string;
793
+ value: (item: P) => boolean | number | string | null | Date;
794
+ };
795
+ };
796
+ };
797
+ };
671
798
 
672
- declare class SocketChannel implements IChatChannel {
673
- private config;
674
- private server;
675
- private chatResolver;
676
- private userResolver;
677
- private callBack;
678
- constructor(config: SocketChannelConfig, server: Server, chatResolver: ChatResolver, userResolver: UserResolver);
679
- listen(callback: (message: IReceivedMessage) => void): void;
680
- connect(): void;
799
+ declare class PgRepositoryBase<P extends Persistent> {
800
+ protected pool: Pool;
801
+ protected config: IPgRepositoryConfig<any>;
802
+ private tableIsCreated;
803
+ schema: string;
804
+ table: string;
805
+ columnsList: string[];
806
+ columnsAndTypes: string;
807
+ columns: string;
808
+ vars: string;
809
+ updates: string;
810
+ addColumns: {
811
+ [columns: string]: {
812
+ type: string;
813
+ value: (item: P) => number | boolean | string | null | Date;
814
+ };
815
+ };
816
+ constructor(pool: Pool, config: IPgRepositoryConfig<any>);
817
+ values(item: P): (string | number | boolean | Date | null)[];
818
+ protected exec(sql: string, values: any[]): Promise<void>;
819
+ protected query(sql: string, values: any[]): Promise<any[]>;
820
+ protected connect(): Promise<Pool>;
821
+ protected ensureTable(): Promise<void>;
822
+ protected ensureColumns(): Promise<void>;
823
+ }
824
+
825
+ declare class PgCrudRepository<P extends Persistent> extends PgRepositoryBase<P> implements ICrudRepository<P> {
826
+ protected readonly config: IPgRepositoryConfig<P>;
827
+ constructor(pool: Pool, config: IPgRepositoryConfig<P>);
828
+ find(id: string): Promise<P | null>;
829
+ findOrThrow(id: string): Promise<P>;
830
+ findAll(): Promise<P[]>;
831
+ create(item: P): Promise<void>;
832
+ update(item: P): Promise<void>;
833
+ discard(item: P): Promise<void>;
834
+ }
835
+
836
+ declare class PgWhatsAppRepository extends PgCrudRepository<WhatsApp> implements IWhatsAppRepository {
837
+ constructor(pool: Pool);
838
+ findBySlug(slug: string): Promise<WhatsApp | null>;
839
+ findByBusinessNumber(number: string): Promise<WhatsApp | null>;
840
+ }
841
+
842
+ type IWabotEnvType = 'development' | 'staging' | 'testing' | 'production';
843
+ declare class WabotEnv {
844
+ private envType;
845
+ constructor();
846
+ isDevelopment(): boolean;
847
+ isProduction(): boolean;
848
+ requireString(varName: string): string;
849
+ }
850
+
851
+ declare class EnvWhatsAppRepository implements IWhatsAppRepository {
852
+ private env;
853
+ constructor(env: WabotEnv);
854
+ findBySlug(slug: string): Promise<WhatsApp | null>;
855
+ findByBusinessNumber(number: string): Promise<WhatsApp | null>;
856
+ private getFromEnvVars;
681
857
  }
682
858
 
683
859
  declare function prepareChatContainer(container: DependencyContainer$1, context: IMessageContext, mindsetCtor?: IConstructor<IMindset>): Promise<DependencyContainer$1>;
@@ -756,92 +932,14 @@ declare class RegisterUserModule {
756
932
  registerUserWithEmail(request: RegisterUserWithEmailRequest): Promise<string>;
757
933
  }
758
934
 
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>;
935
+ interface IHtmlModuleOptions {
936
+ url: string;
937
+ title: string;
765
938
  }
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
- };
939
+ declare function HtmlModule(options: IHtmlModuleOptions): {
940
+ new (): {};
779
941
  };
780
942
 
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
943
  declare class PgUserRepository extends PgCrudRepository<User> implements IUserRepository {
846
944
  constructor(pool: Pool);
847
945
  findByConnection(query: IUserConnection): Promise<User | null>;
@@ -854,12 +952,6 @@ declare class RamUserRepository implements IUserRepository {
854
952
  update(chat: User): Promise<void>;
855
953
  }
856
954
 
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
955
  declare class PgChatRepository extends PgCrudRepository<Chat> implements IChatRepository {
864
956
  constructor(pool: Pool);
865
957
  findByConnection(query: IChatConnection): Promise<Chat | null>;
@@ -872,19 +964,6 @@ declare class PgChatMemory extends PgCrudRepository<ChatItem> implements IChatMe
872
964
  findLastItems(count: number): Promise<ChatItem[]>;
873
965
  }
874
966
 
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
967
  declare class RamChatMemory implements IChatMemory {
889
968
  private memory;
890
969
  findLastItems(count: number): Promise<ChatItem[]>;
@@ -901,4 +980,145 @@ declare class RamChatRepository implements IChatRepository {
901
980
  private getMemory;
902
981
  }
903
982
 
904
- export { AuthenticationModule, Chat, ChatBot, ChatBotAdapter, ChatBotMetadataStore, ChatItem, ChatMemory, ChatRepository, ChatResolver, CmdChannel, Container, ControllerMetadataStore, DeepSeekChatBotAdapter, EmailService, ExpressApp, 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 IDevConnectionRequest, type IDevSendWhatsappRequest, type IDevSendWhatsappTemplateRequest, type IEmailService, 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 IPersistent, type IPgRepositoryConfig, type IReceivedMessage, type IReceivedMessageItem, type IReversibleMapper, type ISendEmailRequest, type IServerConfig, type IServerProvider, type ISqliteRecord, type ISystemFunctionCallItem, type ISystemMessageItem, type ITelegramChannelConfig, type IUserConnection, type IUserData, type IUserRepository, type IWabotEnvType, type IWhatsAppConnection, type IWhatsAppContact, type IWhatsAppMessage, type IWhatsAppMessageListener, 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, SocketIoApp, SqliteChatMemory, SqliteChatRepository, SqliteCrudRepository, SqlitePersistentMapper, SqliteUserRepository, TelegramChannel, TelegramChannelConfig, User, UserRepository, UserResolver, ValidateOneTimePasswordRequest, WabotEnv, WhatsAppChannel, WhatsAppConnection, WhatsAppDevConnection, WhatsAppProdConnection, WhatsAppSender, WhatsappChannelConfig, chatBot, chatController, cmd, container, devWhatsAppListentEvent, devWhatsappEmitEvent, inject, injectable, isOptional, mindset, mindsetFunction, mindsetModule, param, prepareChatContainer, runChannel, runServer, singleton, socket, sqliteMapperFor, telegram, whatsapp };
983
+ interface IGetConfig {
984
+ path?: string;
985
+ }
986
+
987
+ declare function get(config?: IGetConfig): (target: object, propertyKey: string | symbol) => void;
988
+
989
+ interface IPostConfig {
990
+ path?: string;
991
+ }
992
+
993
+ declare function post(config?: IPostConfig): (target: object, propertyKey: string | symbol) => void;
994
+
995
+ interface IRestControllerConfig {
996
+ path: string;
997
+ }
998
+
999
+ declare function restController(config: IRestControllerConfig): (target: IConstructor<any>) => void;
1000
+
1001
+ interface IEndPointMetadata {
1002
+ method: 'get' | 'post';
1003
+ path?: string;
1004
+ controllerConstructor: IConstructor<any>;
1005
+ functionName: string;
1006
+ paramsTypes: any[];
1007
+ }
1008
+
1009
+ interface IRestControllerMetadata {
1010
+ controllerConstructor: IConstructor<any>;
1011
+ path: string;
1012
+ }
1013
+
1014
+ declare class RestControllerMetadataStore {
1015
+ private endPoints;
1016
+ private restControllers;
1017
+ saveControllerMetadata(controllerMetadata: IRestControllerMetadata): void;
1018
+ saveEndPointMetadata(endPointMetadata: IEndPointMetadata): void;
1019
+ getControllerEndPointsInfo(controllerConstructor: IConstructor<any>): {
1020
+ controller: IRestControllerMetadata;
1021
+ method: "get" | "post";
1022
+ path?: string;
1023
+ controllerConstructor: IConstructor<any>;
1024
+ functionName: string;
1025
+ paramsTypes: any[];
1026
+ }[];
1027
+ }
1028
+
1029
+ declare function runRestControllers(controllers: IConstructor<any>[], container: DependencyContainer$1): void;
1030
+
1031
+ declare function isBoolean(): (target: object, propertyKey: string | symbol) => void;
1032
+
1033
+ declare function isDate(): (target: object, propertyKey: string | symbol) => void;
1034
+
1035
+ declare function isNotEmpty(): (target: object, propertyKey: string | symbol) => void;
1036
+
1037
+ declare function isNumber(): (target: object, propertyKey: string | symbol) => void;
1038
+
1039
+ declare function isOptional(): (target: object, propertyKey: string | symbol) => void;
1040
+
1041
+ declare function isPresent(): (target: object, propertyKey: string | symbol) => void;
1042
+
1043
+ declare function isString(): (target: object, propertyKey: string | symbol) => void;
1044
+
1045
+ declare function max(limit: any): (target: object, propertyKey: string | symbol) => void;
1046
+
1047
+ declare function min(limit: any): (target: object, propertyKey: string | symbol) => void;
1048
+
1049
+ declare function validable<A>(): (target: IConstructor<A>) => void;
1050
+
1051
+ interface IValidationError {
1052
+ description: string;
1053
+ }
1054
+ interface IModelValidationError {
1055
+ model: IValidationError[];
1056
+ properties: {
1057
+ name: string;
1058
+ errors: IValidationError[];
1059
+ }[];
1060
+ }
1061
+ interface IValidationResult<V> {
1062
+ value?: V;
1063
+ error?: IValidationError;
1064
+ }
1065
+ interface IModelValidationResult<V> {
1066
+ value?: V;
1067
+ error?: IModelValidationError;
1068
+ }
1069
+ type IValidator = (value: any, options: any) => IValidationResult<any>;
1070
+ interface IPropertyValidatorInfo {
1071
+ propertyName: string;
1072
+ validator: IValidator;
1073
+ validatorOptions?: any;
1074
+ }
1075
+ type IModelValidatorsInfo<V> = {
1076
+ modelConstructor: IConstructor<V>;
1077
+ properties: {
1078
+ [prop: string]: {
1079
+ isOptional?: boolean;
1080
+ validators?: IPropertyValidatorInfo[];
1081
+ } | undefined;
1082
+ };
1083
+ };
1084
+
1085
+ interface IValidatorMetadata {
1086
+ modelConstructor: IConstructor<any>;
1087
+ propertyName: string;
1088
+ validator: IValidator;
1089
+ validatorOptions?: any;
1090
+ }
1091
+
1092
+ declare class ValidationMetadataStore {
1093
+ private validators;
1094
+ saveValidatorMetadata(validatorMetadata: IValidatorMetadata): void;
1095
+ getModelValidatorsInfo<V>(modelConstructor: IConstructor<V>): IModelValidatorsInfo<V>;
1096
+ }
1097
+
1098
+ declare function validateIsBoolean(value: any): IValidationResult<boolean>;
1099
+
1100
+ declare function validateIsDate(value: any): IValidationResult<Date>;
1101
+
1102
+ declare function validateIsNotEmpty(value: any): IValidationResult<any>;
1103
+
1104
+ declare function validateIsNumber(value: any): IValidationResult<number>;
1105
+
1106
+ declare function validateIsString(value: any): IValidationResult<string>;
1107
+
1108
+ interface IValidateMaxOptions {
1109
+ limit: any;
1110
+ }
1111
+ declare function validateMax(value: any, options: IValidateMaxOptions): IValidationResult<any>;
1112
+
1113
+ interface IValidateMinOptions {
1114
+ limit: any;
1115
+ }
1116
+ declare function validateMin(value: any, options: IValidateMinOptions): IValidationResult<any>;
1117
+
1118
+ declare function validateIsPresent(value: any): IValidationResult<any>;
1119
+
1120
+ declare function validateModel<V>(value: any, info: IModelValidatorsInfo<V>): IModelValidationResult<V>;
1121
+
1122
+ declare function validateModel2<V>(value: any, modelConstructor: IConstructor<V>): IModelValidationResult<V>;
1123
+
1124
+ export { AuthenticationModule, Chat, ChatBot, ChatBotAdapter, ChatBotMetadataStore, ChatItem, ChatMemory, ChatRepository, ChatResolver, CmdChannel, Container, ControllerMetadataStore, DeepSeekChatBotAdapter, EmailService, EnvWhatsAppRepository, ExpressProvider, HtmlModule, 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 IEndPointMetadata, type IGetConfig, type IGetWhatsAppTemplateRequest, type IHtmlModuleOptions, 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 IModelValidationError, type IModelValidationResult, type IModelValidatorsInfo, type IOtpService, type IParamConfig, type IParamDecoration, type IPersistentData, type IPgRepositoryConfig, type IPostConfig, type IPropertyValidatorInfo, type IReceivedMessage, type IReceivedMessageItem, type IRestControllerConfig, type IRestControllerMetadata, 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 IValidateMaxOptions, type IValidateMinOptions, type IValidationError, type IValidationResult, type IValidator, type IValidatorMetadata, 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, RestControllerMetadataStore, SendOneTimePasswordRequest, SocketChannel, SocketChannelConfig, SocketServerProvider, TelegramChannel, TelegramChannelConfig, User, UserRepository, UserResolver, ValidateOneTimePasswordRequest, ValidationMetadataStore, WabotEnv, WhatsApp, WhatsAppChannel, WhatsAppReceiver, WhatsAppReceiverByDevConnection, WhatsAppReceiverByWebHook, WhatsAppRepository, WhatsAppSender, WhatsAppSenderByCloudApi, WhatsAppSenderByDevConnection, WhatsappChannelConfig, chatBot, chatController, cmd, container, get, inject, injectable, isBoolean, isDate, isNotEmpty, isNumber, isOptional, isPresent, isString, max, min, mindset, mindsetFunction, mindsetModule, param, post, prepareChatContainer, restController, runChannel, runRestControllers, runServer, singleton, socket, telegram, validable, validateIsBoolean, validateIsDate, validateIsNotEmpty, validateIsNumber, validateIsPresent, validateIsString, validateMax, validateMin, validateModel, validateModel2, whatsapp };