@wabot-dev/framework 0.0.16 → 0.0.50

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 (111) hide show
  1. package/dist/src/_virtual/_commonjsHelpers.js +5 -0
  2. package/dist/src/_virtual/cjs.js +7 -0
  3. package/dist/src/ai/deepseek/DeepSeekChatBotAdapter.js +107 -0
  4. package/dist/src/ai/openia/OpenaiChatBotAdapter.js +9 -7
  5. package/dist/src/channels/cmd/@cmd.js +0 -4
  6. package/dist/src/channels/cmd/CmdChannel.js +0 -4
  7. package/dist/src/channels/express/ExpressProvider.js +46 -0
  8. package/dist/src/channels/http/HttpServerProvider.js +31 -0
  9. package/dist/src/channels/socket/@socket.js +20 -0
  10. package/dist/src/channels/socket/SocketChannel.js +79 -0
  11. package/dist/src/channels/socket/SocketChannelConfig.js +15 -0
  12. package/dist/src/channels/socket/SocketServerProvider.js +50 -0
  13. package/dist/src/channels/telegram/@telegram.js +0 -4
  14. package/dist/src/channels/telegram/TelegramChannel.js +0 -4
  15. package/dist/src/channels/wabot/WabotDevConnection.js +57 -0
  16. package/dist/src/channels/wabot/WabotDevSocketContracts.js +10 -0
  17. package/dist/src/channels/whatsapp/@whatsapp.js +0 -4
  18. package/dist/src/channels/whatsapp/EnvWhatsAppRepository.js +49 -0
  19. package/dist/src/channels/whatsapp/PgWhatsAppRepository.js +41 -0
  20. package/dist/src/channels/whatsapp/WhatsApp.js +32 -0
  21. package/dist/src/channels/whatsapp/WhatsAppChannel.js +33 -32
  22. package/dist/src/channels/whatsapp/{WhatsAppConnection.js → WhatsAppReceiver.js} +4 -6
  23. package/dist/src/channels/whatsapp/WhatsAppReceiverByDevConnection.js +32 -0
  24. package/dist/src/channels/whatsapp/WhatsAppReceiverByWebHook.js +63 -0
  25. package/dist/src/channels/whatsapp/WhatsAppRepository.js +10 -0
  26. package/dist/src/channels/whatsapp/WhatsAppSender.js +99 -0
  27. package/dist/src/channels/whatsapp/WhatsAppSenderByCloudApi.js +124 -0
  28. package/dist/src/channels/whatsapp/WhatsAppSenderByDevConnection.js +61 -0
  29. package/dist/src/chatbot/ChatBotAdapter.js +1 -5
  30. package/dist/src/chatbot/metadata/@chatBot.js +0 -5
  31. package/dist/src/chatbot/metadata/ChatBotMetadataStore.js +0 -5
  32. package/dist/src/controller/metadata/ControllerMetadataStore.js +0 -2
  33. package/dist/src/controller/metadata/controller/@chatController.js +0 -2
  34. package/dist/src/core/IMessageContext.js +0 -2
  35. package/dist/src/env/WabotEnv.js +6 -0
  36. package/dist/src/index.d.ts +454 -163
  37. package/dist/src/index.js +56 -21
  38. package/dist/src/mindset/MindsetOperator.js +1 -3
  39. package/dist/src/mindset/metadata/MindsetMetadataStore.js +0 -2
  40. package/dist/src/mindset/metadata/mindsets/@mindset.js +0 -2
  41. package/dist/src/mindset/metadata/modules/@mindsetModule.js +0 -2
  42. package/dist/src/node_modules/@selderee/plugin-htmlparser2/lib/hp2-builder.js +90 -0
  43. package/dist/src/node_modules/deepmerge/dist/cjs.js +142 -0
  44. package/dist/src/node_modules/dom-serializer/lib/esm/foreignNames.js +102 -0
  45. package/dist/src/node_modules/dom-serializer/lib/esm/index.js +186 -0
  46. package/dist/src/node_modules/domelementtype/lib/esm/index.js +53 -0
  47. package/dist/src/node_modules/domhandler/lib/esm/index.js +148 -0
  48. package/dist/src/node_modules/domhandler/lib/esm/node.js +334 -0
  49. package/dist/src/node_modules/entities/lib/esm/decode.js +458 -0
  50. package/dist/src/node_modules/entities/lib/esm/decode_codepoint.js +62 -0
  51. package/dist/src/node_modules/entities/lib/esm/escape.js +99 -0
  52. package/dist/src/node_modules/entities/lib/esm/generated/decode-data-html.js +8 -0
  53. package/dist/src/node_modules/entities/lib/esm/generated/decode-data-xml.js +8 -0
  54. package/dist/src/node_modules/html-to-text/lib/html-to-text.js +2147 -0
  55. package/dist/src/node_modules/htmlparser2/lib/esm/Parser.js +491 -0
  56. package/dist/src/node_modules/htmlparser2/lib/esm/Tokenizer.js +928 -0
  57. package/dist/src/node_modules/htmlparser2/lib/esm/index.js +18 -0
  58. package/dist/src/node_modules/leac/lib/leac.js +3 -0
  59. package/dist/src/node_modules/parseley/lib/parseley.js +270 -0
  60. package/dist/src/node_modules/peberminta/lib/core.js +171 -0
  61. package/dist/src/node_modules/selderee/lib/selderee.js +380 -0
  62. package/dist/src/pre-made/module/authentication/requests/SendOneTimePasswordRequest.js +0 -2
  63. package/dist/src/pre-made/module/authentication/requests/ValidateOneTimePasswordRequest.js +0 -2
  64. package/dist/src/pre-made/module/html/HtmlModule.js +70 -0
  65. package/dist/src/pre-made/module/register-user/requests/RegisterUserWithEmailRequest.js +0 -2
  66. package/dist/src/pre-made/repository/chat/pg/PgChatMemory.js +1 -7
  67. package/dist/src/pre-made/repository/chat/pg/PgChatRepository.js +0 -5
  68. package/dist/src/pre-made/repository/user/pg/PgUserRepository.js +0 -5
  69. package/dist/src/repository/pg/PgCrudRepository.js +0 -1
  70. package/dist/src/rest-controller/metadata/@get.js +19 -0
  71. package/dist/src/rest-controller/metadata/@post.js +19 -0
  72. package/dist/src/rest-controller/metadata/@restController.js +15 -0
  73. package/dist/src/rest-controller/metadata/RestControllerMetadataStore.js +37 -0
  74. package/dist/src/rest-controller/runRestControllers.js +74 -0
  75. package/dist/src/server/prepareChatContainer.js +4 -4
  76. package/dist/src/server/runChannel.js +2 -10
  77. package/dist/src/server/runServer.js +0 -43
  78. package/dist/src/validation/metadata/@isBoolean.js +17 -0
  79. package/dist/src/validation/metadata/@isDate.js +17 -0
  80. package/dist/src/validation/metadata/@isNotEmpty.js +17 -0
  81. package/dist/src/validation/metadata/@isNumber.js +17 -0
  82. package/dist/src/validation/metadata/@isOptional.js +17 -0
  83. package/dist/src/validation/metadata/@isPresent.js +17 -0
  84. package/dist/src/validation/metadata/@isString.js +17 -0
  85. package/dist/src/validation/metadata/@max.js +18 -0
  86. package/dist/src/validation/metadata/@min.js +18 -0
  87. package/dist/src/validation/metadata/@validable.js +14 -0
  88. package/dist/src/validation/metadata/ValidationMetadataStore.js +55 -0
  89. package/dist/src/validation/validateModel2.js +11 -0
  90. package/dist/src/validation/validators/validateIsBoolean.js +12 -0
  91. package/dist/src/validation/validators/validateIsDate.js +16 -0
  92. package/dist/src/validation/validators/validateIsNotEmpty.js +12 -0
  93. package/dist/src/validation/validators/validateIsNumber.js +12 -0
  94. package/dist/src/validation/validators/validateIsOptional.js +5 -0
  95. package/dist/src/validation/validators/validateIsPresent.js +12 -0
  96. package/dist/src/validation/validators/validateIsString.js +12 -0
  97. package/dist/src/validation/validators/validateMax.js +17 -0
  98. package/dist/src/validation/validators/validateMin.js +17 -0
  99. package/dist/src/validation/validators/validateModel.js +47 -0
  100. package/package.json +4 -6
  101. package/dist/src/channels/whatsapp/WhatsAppDevConnection.js +0 -61
  102. package/dist/src/channels/whatsapp/WhatsAppProdConnection.js +0 -36
  103. package/dist/src/channels/whatsapp/whatsAppDevSocketContracts.js +0 -9
  104. package/dist/src/controller/express/Express.js +0 -5
  105. package/dist/src/controller/socket.io/SocketIO.js +0 -5
  106. package/dist/src/mindset/metadata/params/@isOptional.js +0 -21
  107. package/dist/src/pre-made/repository/chat/sqlite/SqliteChatMemory.js +0 -23
  108. package/dist/src/pre-made/repository/chat/sqlite/SqliteChatRepository.js +0 -30
  109. package/dist/src/pre-made/repository/user/sqlite/SqliteUserRepository.js +0 -23
  110. package/dist/src/repository/sqlite/SqliteCrudRepository.js +0 -85
  111. package/dist/src/repository/sqlite/SqlitePersistentMapper.js +0 -17
@@ -1,15 +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 as Server$1 } from 'socket.io';
7
+ import { Socket } from 'socket.io-client';
8
+ import { Pool } from 'pg';
6
9
  import * as tsyringe from 'tsyringe';
7
10
  import { DependencyContainer as DependencyContainer$1 } from 'tsyringe';
8
11
  export { DependencyContainer } from 'tsyringe';
9
- import { Pool } from 'pg';
10
- import { Database } from 'sqlite';
11
- import sqlite3 from 'sqlite3';
12
- export { Server as SocketIo } from 'socket.io';
13
12
 
14
13
  interface IMindsetFunctionConfig {
15
14
  description: string;
@@ -27,12 +26,12 @@ interface IMindsetFunctionDecoration {
27
26
  decorationConfig: any;
28
27
  }
29
28
 
30
- interface IPersistent {
29
+ interface IPersistentData {
31
30
  id?: string;
32
31
  createdAt?: number | null;
33
32
  discardedAt?: number | null;
34
33
  }
35
- declare class Persistent<D extends IPersistent = IPersistent> {
34
+ declare class Persistent<D extends IPersistentData = IPersistentData> {
36
35
  protected data: D;
37
36
  constructor(data: D);
38
37
  getId(): string;
@@ -49,7 +48,7 @@ interface IChatConnection {
49
48
  channelName: string;
50
49
  id: string;
51
50
  }
52
- interface IChatData extends IPersistent {
51
+ interface IChatData extends IPersistentData {
53
52
  type: IChatType;
54
53
  connections: IChatConnection[];
55
54
  }
@@ -73,7 +72,7 @@ interface IUserConnection {
73
72
  channelName: string;
74
73
  id: string;
75
74
  }
76
- interface IUserData extends IPersistent {
75
+ interface IUserData extends IPersistentData {
77
76
  shortName: string;
78
77
  connections: IUserConnection[];
79
78
  keyValueData: {
@@ -227,10 +226,9 @@ interface IMindsetModuleDecoration {
227
226
  decorationConfig: any;
228
227
  }
229
228
 
230
- declare function isOptional(): PropertyDecorator;
231
-
232
229
  interface IParamConfig {
233
230
  name?: string;
231
+ optional?: boolean;
234
232
  description: string;
235
233
  }
236
234
 
@@ -367,9 +365,19 @@ declare class ChatBot implements IChatBot {
367
365
  protected processLoop(callback: (message: IChatMessage) => void): Promise<void>;
368
366
  }
369
367
 
368
+ declare class DeepSeekChatBotAdapter extends ChatBotAdapter {
369
+ private deepSeek;
370
+ private model;
371
+ constructor(mindset: MindsetOperator);
372
+ validateEnvVariables(envVariables: (string | undefined)[]): void;
373
+ generateNextChatItem(chatItems: ChatItem[]): Promise<ChatItem>;
374
+ private mapChatItems;
375
+ }
376
+
370
377
  declare class OpenaiChatBotAdapter extends ChatBotAdapter {
371
378
  private openai;
372
379
  private model;
380
+ private logger;
373
381
  constructor(mindset: MindsetOperator);
374
382
  generateNextChatItem(chatItems: ChatItem[]): Promise<ChatItem>;
375
383
  private mapChatItems;
@@ -426,10 +434,6 @@ declare class ControllerMetadataStore {
426
434
  } | null;
427
435
  }
428
436
 
429
- declare const ExpressApp: unique symbol;
430
-
431
- declare const SocketIoApp: unique symbol;
432
-
433
437
  declare class CmdChannel implements IChatChannel {
434
438
  private chatResolver;
435
439
  private userResolver;
@@ -440,6 +444,63 @@ declare class CmdChannel implements IChatChannel {
440
444
  connect(): void;
441
445
  }
442
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
+
443
504
  interface ITelegramChannelConfig {
444
505
  botToken: string;
445
506
  }
@@ -471,6 +532,29 @@ declare class WhatsappChannelConfig implements IWhatsappChannelConfig {
471
532
 
472
533
  declare function whatsapp(config: IWhatsappChannelConfig): (target: object, propertyKey: string | symbol) => void;
473
534
 
535
+ type IWhatsAppTemplateParameter = {
536
+ type: 'text';
537
+ text: string;
538
+ parameter_name?: string;
539
+ } | {
540
+ type: 'currency';
541
+ currency: {
542
+ fallback_value: string;
543
+ code: string;
544
+ amount_1000: number;
545
+ };
546
+ } | {
547
+ type: 'date_time';
548
+ date_time: {
549
+ fallback_value: string;
550
+ };
551
+ };
552
+ interface IWhatsAppTemplateMessage {
553
+ templateName: string;
554
+ languageCode: string;
555
+ parameters: IWhatsAppTemplateParameter[];
556
+ }
557
+
474
558
  interface IWhatsAppWebhookPayload {
475
559
  object: 'whatsapp_business_account';
476
560
  entry: IEntry[];
@@ -523,19 +607,30 @@ interface IAudioMessage extends IBaseMessage {
523
607
  };
524
608
  }
525
609
 
526
- type IWabotEnvType = 'development' | 'staging' | 'testing' | 'production';
527
- declare class WabotEnv {
528
- private envType;
529
- constructor();
530
- isDevelopment(): boolean;
531
- isProduction(): boolean;
610
+ interface IWhatsAppBusinessNumber {
611
+ id: string;
612
+ number: string;
532
613
  }
533
-
534
- type IWhatsAppMessageListener = (message: IConnectionChatMessage) => Promise<void>;
535
- interface IWhatsAppConnection {
536
- listenMessage(businessNumber: string, listener: IWhatsAppMessageListener): void;
537
- sendWhatsApp(businessNumber: string, to: string, replyMessage: IChatMessage): Promise<void>;
538
- connect(): void;
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;
539
634
  }
540
635
 
541
636
  declare class Logger {
@@ -550,61 +645,213 @@ declare class Logger {
550
645
  private log;
551
646
  }
552
647
 
553
- 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 {
554
654
  protected logger: Logger;
555
655
  private listeners;
556
656
  constructor(logger: Logger);
557
- abstract sendWhatsApp(businessNumber: string, to: string, chatMessage: IChatMessage): Promise<void>;
558
- abstract connect(): void;
559
- listenMessage(businessNumber: string, listener: IWhatsAppMessageListener): void;
657
+ abstract connect(): Promise<void>;
658
+ listenMessage(request: IListenWhatsAppMessageRequest): void;
560
659
  protected handlePayload(payload: IWhatsAppWebhookPayload): Promise<void>;
561
660
  private emmitMessage;
562
661
  }
563
662
 
564
- declare class WhatsAppDevConnection extends WhatsAppConnection implements IWhatsAppConnection {
565
- private devProxy;
566
- private devProxySocket;
567
- private devToken?;
568
- private connected;
569
- constructor();
570
- sendWhatsApp(businessNumber: string, to: string, chatMessage: IChatMessage): Promise<void>;
571
- connect(): void;
663
+ interface IWhatsAppRepository {
664
+ findBySlug(slug: string): Promise<WhatsApp | null>;
665
+ findByBusinessNumber(number: string): Promise<WhatsApp | null>;
572
666
  }
573
667
 
574
- declare class WhatsAppProdConnection implements IWhatsAppConnection {
575
- private express;
576
- constructor(express: Express);
577
- listenMessage(businessNumber: string, listener: IWhatsAppMessageListener): void;
578
- sendWhatsApp(businessNumber: string, to: string, replyMessage: IChatMessage): Promise<void>;
579
- 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;
580
722
  }
581
723
 
582
724
  declare class WhatsAppChannel implements IChatChannel {
583
725
  private config;
584
726
  private chatResolver;
585
727
  private userResolver;
586
- private wabotEnv;
728
+ private sender;
729
+ private receiver;
587
730
  private logger;
588
- private whatsAppConection;
589
- 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);
590
732
  listen(callback: (message: IReceivedMessage) => void): void;
591
733
  connect(): void;
592
734
  }
593
735
 
594
- declare const devWhatsAppListentEvent: {
595
- readonly DEV_WATSAPP_WEBHOOK: "dev-whatsapp-webhook";
596
- };
597
- declare const devWhatsappEmitEvent: {
598
- readonly DEV_CONNECTION: "dev-connection";
599
- readonly DEV_SEND_WHATSAPP: "dev-send-whatsapp";
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>;
744
+ }
745
+
746
+ declare class WhatsAppReceiverByDevConnection extends WhatsAppReceiver {
747
+ private wabotDevConnection;
748
+ constructor(wabotDevConnection: WabotDevConnection);
749
+ connect(): Promise<void>;
750
+ }
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>;
759
+ }
760
+
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>;
767
+ }
768
+
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>;
774
+ }
775
+
776
+ interface ICrudRepository<T> {
777
+ find(id: string): Promise<T | null>;
778
+ findAll(id: string): Promise<T[]>;
779
+ create(item: T): Promise<void>;
780
+ update(item: T): Promise<void>;
781
+ discard(item: T): Promise<void>;
782
+ }
783
+
784
+ type IPgRepositoryConfig<P extends Persistent> = {
785
+ schema?: string;
786
+ table: string;
787
+ constructor: IConstructor<P>;
788
+ add?: {
789
+ columns: {
790
+ [column: string]: {
791
+ type: string;
792
+ value: (item: P) => boolean | number | string | null | Date;
793
+ };
794
+ };
795
+ };
600
796
  };
601
- interface IDevConnectionRequest {
602
- token: string;
797
+
798
+ declare class PgRepositoryBase<P extends Persistent> {
799
+ protected pool: Pool;
800
+ protected config: IPgRepositoryConfig<any>;
801
+ private tableIsCreated;
802
+ schema: string;
803
+ table: string;
804
+ columnsList: string[];
805
+ columnsAndTypes: string;
806
+ columns: string;
807
+ vars: string;
808
+ updates: string;
809
+ addColumns: {
810
+ [columns: string]: {
811
+ type: string;
812
+ value: (item: P) => number | boolean | string | null | Date;
813
+ };
814
+ };
815
+ constructor(pool: Pool, config: IPgRepositoryConfig<any>);
816
+ values(item: P): (string | number | boolean | Date | null)[];
817
+ protected exec(sql: string, values: any[]): Promise<void>;
818
+ protected query(sql: string, values: any[]): Promise<any[]>;
819
+ protected connect(): Promise<Pool>;
820
+ protected ensureTable(): Promise<void>;
821
+ protected ensureColumns(): Promise<void>;
603
822
  }
604
- interface IDevSendWhatsappRequest {
605
- from: string;
606
- to: string;
607
- message: IChatMessage;
823
+
824
+ declare class PgCrudRepository<P extends Persistent> extends PgRepositoryBase<P> implements ICrudRepository<P> {
825
+ protected readonly config: IPgRepositoryConfig<P>;
826
+ constructor(pool: Pool, config: IPgRepositoryConfig<P>);
827
+ find(id: string): Promise<P | null>;
828
+ findAll(): Promise<P[]>;
829
+ create(item: P): Promise<void>;
830
+ update(item: P): Promise<void>;
831
+ discard(item: P): Promise<void>;
832
+ }
833
+
834
+ declare class PgWhatsAppRepository extends PgCrudRepository<WhatsApp> implements IWhatsAppRepository {
835
+ constructor(pool: Pool);
836
+ findBySlug(slug: string): Promise<WhatsApp | null>;
837
+ findByBusinessNumber(number: string): Promise<WhatsApp | null>;
838
+ }
839
+
840
+ type IWabotEnvType = 'development' | 'staging' | 'testing' | 'production';
841
+ declare class WabotEnv {
842
+ private envType;
843
+ constructor();
844
+ isDevelopment(): boolean;
845
+ isProduction(): boolean;
846
+ requireString(varName: string): string;
847
+ }
848
+
849
+ declare class EnvWhatsAppRepository implements IWhatsAppRepository {
850
+ private env;
851
+ constructor(env: WabotEnv);
852
+ findBySlug(slug: string): Promise<WhatsApp | null>;
853
+ findByBusinessNumber(number: string): Promise<WhatsApp | null>;
854
+ private getFromEnvVars;
608
855
  }
609
856
 
610
857
  declare function prepareChatContainer(container: DependencyContainer$1, context: IMessageContext, mindsetCtor?: IConstructor<IMindset>): Promise<DependencyContainer$1>;
@@ -683,92 +930,14 @@ declare class RegisterUserModule {
683
930
  registerUserWithEmail(request: RegisterUserWithEmailRequest): Promise<string>;
684
931
  }
685
932
 
686
- interface ICrudRepository<T> {
687
- find(id: string): Promise<T | null>;
688
- findAll(id: string): Promise<T[]>;
689
- create(item: T): Promise<void>;
690
- update(item: T): Promise<void>;
691
- discard(item: T): Promise<void>;
933
+ interface IHtmlModuleOptions {
934
+ url: string;
935
+ title: string;
692
936
  }
693
-
694
- type IPgRepositoryConfig<P extends Persistent> = {
695
- schema?: string;
696
- table: string;
697
- constructor: IConstructor<P>;
698
- add?: {
699
- columns: {
700
- [column: string]: {
701
- type: string;
702
- value: (item: P) => boolean | number | string | null | Date;
703
- };
704
- };
705
- };
937
+ declare function HtmlModule(options: IHtmlModuleOptions): {
938
+ new (): {};
706
939
  };
707
940
 
708
- declare class PgRepositoryBase<P extends Persistent> {
709
- protected pool: Pool;
710
- protected config: IPgRepositoryConfig<any>;
711
- private tableIsCreated;
712
- schema: string;
713
- table: string;
714
- columnsList: string[];
715
- columnsAndTypes: string;
716
- columns: string;
717
- vars: string;
718
- updates: string;
719
- addColumns: {
720
- [columns: string]: {
721
- type: string;
722
- value: (item: P) => number | boolean | string | null | Date;
723
- };
724
- };
725
- constructor(pool: Pool, config: IPgRepositoryConfig<any>);
726
- values(item: P): (string | number | boolean | Date | null)[];
727
- protected exec(sql: string, values: any[]): Promise<void>;
728
- protected query(sql: string, values: any[]): Promise<any[]>;
729
- protected connect(): Promise<Pool>;
730
- protected ensureTable(): Promise<void>;
731
- protected ensureColumns(): Promise<void>;
732
- }
733
-
734
- declare class PgCrudRepository<P extends Persistent> extends PgRepositoryBase<P> implements ICrudRepository<P> {
735
- protected readonly config: IPgRepositoryConfig<P>;
736
- constructor(pool: Pool, config: IPgRepositoryConfig<P>);
737
- find(id: string): Promise<P | null>;
738
- findAll(): Promise<P[]>;
739
- create(item: P): Promise<void>;
740
- update(item: P): Promise<void>;
741
- discard(item: P): Promise<void>;
742
- }
743
-
744
- interface ISqliteRecord {
745
- id: string;
746
- data: string;
747
- }
748
-
749
- declare class SqliteCrudRepository<P extends Persistent> implements ICrudRepository<P> {
750
- private table;
751
- private dbPath;
752
- private mapper;
753
- private tableCreated;
754
- constructor(table: string, dbPath: string, mapper: IReversibleMapper<P, string>);
755
- find(id: string): Promise<P | null>;
756
- findAll(): Promise<P[]>;
757
- create(item: P): Promise<void>;
758
- update(item: P): Promise<void>;
759
- discard(item: P): Promise<void>;
760
- protected getDb(): Promise<Database<sqlite3.Database, sqlite3.Statement>>;
761
- protected createTable(db: Database<sqlite3.Database, sqlite3.Statement>): Promise<void>;
762
- }
763
-
764
- declare class SqlitePersistentMapper<P extends Persistent> implements IReversibleMapper<P, string> {
765
- private ctor;
766
- constructor(ctor: IConstructor<P>);
767
- map(input: P): string;
768
- rev(input: string): P;
769
- }
770
- declare function sqliteMapperFor<P extends Persistent>(ctor: IConstructor<P>): SqlitePersistentMapper<P>;
771
-
772
941
  declare class PgUserRepository extends PgCrudRepository<User> implements IUserRepository {
773
942
  constructor(pool: Pool);
774
943
  findByConnection(query: IUserConnection): Promise<User | null>;
@@ -781,12 +950,6 @@ declare class RamUserRepository implements IUserRepository {
781
950
  update(chat: User): Promise<void>;
782
951
  }
783
952
 
784
- declare class SqliteUserRepository extends SqliteCrudRepository<User> implements IUserRepository {
785
- constructor();
786
- findByConnection(query: IUserConnection): Promise<User | null>;
787
- static getDbPath(): string;
788
- }
789
-
790
953
  declare class PgChatRepository extends PgCrudRepository<Chat> implements IChatRepository {
791
954
  constructor(pool: Pool);
792
955
  findByConnection(query: IChatConnection): Promise<Chat | null>;
@@ -799,19 +962,6 @@ declare class PgChatMemory extends PgCrudRepository<ChatItem> implements IChatMe
799
962
  findLastItems(count: number): Promise<ChatItem[]>;
800
963
  }
801
964
 
802
- declare class SqliteChatMemory extends SqliteCrudRepository<ChatItem> implements IChatMemory {
803
- constructor(chatId: string);
804
- findLastItems(count: number): Promise<ChatItem[]>;
805
- static getDbPath(chatId: string): string;
806
- }
807
-
808
- declare class SqliteChatRepository extends SqliteCrudRepository<Chat> implements IChatRepository {
809
- constructor();
810
- findByConnection(query: IChatConnection): Promise<Chat | null>;
811
- findMemory(chatId: string): Promise<IChatMemory | null>;
812
- static getDbPath(): string;
813
- }
814
-
815
965
  declare class RamChatMemory implements IChatMemory {
816
966
  private memory;
817
967
  findLastItems(count: number): Promise<ChatItem[]>;
@@ -828,4 +978,145 @@ declare class RamChatRepository implements IChatRepository {
828
978
  private getMemory;
829
979
  }
830
980
 
831
- export { AuthenticationModule, Chat, ChatBot, ChatBotAdapter, ChatBotMetadataStore, ChatItem, ChatMemory, ChatRepository, ChatResolver, CmdChannel, Container, ControllerMetadataStore, 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 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 IWhatsAppContact, type IWhatsAppMessage, 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, SocketIoApp, SqliteChatMemory, SqliteChatRepository, SqliteCrudRepository, SqlitePersistentMapper, SqliteUserRepository, TelegramChannel, TelegramChannelConfig, User, UserRepository, UserResolver, ValidateOneTimePasswordRequest, WabotEnv, WhatsAppChannel, WhatsappChannelConfig, chatBot, chatController, cmd, container, devWhatsAppListentEvent, devWhatsappEmitEvent, inject, injectable, isOptional, mindset, mindsetFunction, mindsetModule, param, prepareChatContainer, runChannel, runServer, singleton, sqliteMapperFor, telegram, whatsapp };
981
+ interface IGetConfig {
982
+ path?: string;
983
+ }
984
+
985
+ declare function get(config?: IGetConfig): (target: object, propertyKey: string | symbol) => void;
986
+
987
+ interface IPostConfig {
988
+ path?: string;
989
+ }
990
+
991
+ declare function post(config?: IPostConfig): (target: object, propertyKey: string | symbol) => void;
992
+
993
+ interface IRestControllerConfig {
994
+ path: string;
995
+ }
996
+
997
+ declare function restController(config: IRestControllerConfig): (target: IConstructor<any>) => void;
998
+
999
+ interface IEndPointMetadata {
1000
+ method: 'get' | 'post';
1001
+ path?: string;
1002
+ controllerConstructor: IConstructor<any>;
1003
+ functionName: string;
1004
+ paramsTypes: any[];
1005
+ }
1006
+
1007
+ interface IRestControllerMetadata {
1008
+ controllerConstructor: IConstructor<any>;
1009
+ path: string;
1010
+ }
1011
+
1012
+ declare class RestControllerMetadataStore {
1013
+ private endPoints;
1014
+ private restControllers;
1015
+ saveControllerMetadata(controllerMetadata: IRestControllerMetadata): void;
1016
+ saveEndPointMetadata(endPointMetadata: IEndPointMetadata): void;
1017
+ getControllerEndPointsInfo(controllerConstructor: IConstructor<any>): {
1018
+ controller: IRestControllerMetadata;
1019
+ method: "get" | "post";
1020
+ path?: string;
1021
+ controllerConstructor: IConstructor<any>;
1022
+ functionName: string;
1023
+ paramsTypes: any[];
1024
+ }[];
1025
+ }
1026
+
1027
+ declare function runRestControllers(controllers: IConstructor<any>[], container: DependencyContainer$1): void;
1028
+
1029
+ declare function isBoolean(): (target: object, propertyKey: string | symbol) => void;
1030
+
1031
+ declare function isDate(): (target: object, propertyKey: string | symbol) => void;
1032
+
1033
+ declare function isNotEmpty(): (target: object, propertyKey: string | symbol) => void;
1034
+
1035
+ declare function isNumber(): (target: object, propertyKey: string | symbol) => void;
1036
+
1037
+ declare function isOptional(): (target: object, propertyKey: string | symbol) => void;
1038
+
1039
+ declare function isPresent(): (target: object, propertyKey: string | symbol) => void;
1040
+
1041
+ declare function isString(): (target: object, propertyKey: string | symbol) => void;
1042
+
1043
+ declare function max(limit: any): (target: object, propertyKey: string | symbol) => void;
1044
+
1045
+ declare function min(limit: any): (target: object, propertyKey: string | symbol) => void;
1046
+
1047
+ declare function validable<A>(): (target: IConstructor<A>) => void;
1048
+
1049
+ interface IValidationError {
1050
+ description: string;
1051
+ }
1052
+ interface IModelValidationError {
1053
+ model: IValidationError[];
1054
+ properties: {
1055
+ name: string;
1056
+ errors: IValidationError[];
1057
+ }[];
1058
+ }
1059
+ interface IValidationResult<V> {
1060
+ value?: V;
1061
+ error?: IValidationError;
1062
+ }
1063
+ interface IModelValidationResult<V> {
1064
+ value?: V;
1065
+ error?: IModelValidationError;
1066
+ }
1067
+ type IValidator = (value: any, options: any) => IValidationResult<any>;
1068
+ interface IPropertyValidatorInfo {
1069
+ propertyName: string;
1070
+ validator: IValidator;
1071
+ validatorOptions?: any;
1072
+ }
1073
+ type IModelValidatorsInfo<V> = {
1074
+ modelConstructor: IConstructor<V>;
1075
+ properties: {
1076
+ [prop: string]: {
1077
+ isOptional?: boolean;
1078
+ validators?: IPropertyValidatorInfo[];
1079
+ } | undefined;
1080
+ };
1081
+ };
1082
+
1083
+ interface IValidatorMetadata {
1084
+ modelConstructor: IConstructor<any>;
1085
+ propertyName: string;
1086
+ validator: IValidator;
1087
+ validatorOptions?: any;
1088
+ }
1089
+
1090
+ declare class ValidationMetadataStore {
1091
+ private validators;
1092
+ saveValidatorMetadata(validatorMetadata: IValidatorMetadata): void;
1093
+ getModelValidatorsInfo<V>(modelConstructor: IConstructor<V>): IModelValidatorsInfo<V>;
1094
+ }
1095
+
1096
+ declare function validateIsBoolean(value: any): IValidationResult<boolean>;
1097
+
1098
+ declare function validateIsDate(value: any): IValidationResult<Date>;
1099
+
1100
+ declare function validateIsNotEmpty(value: any): IValidationResult<any>;
1101
+
1102
+ declare function validateIsNumber(value: any): IValidationResult<number>;
1103
+
1104
+ declare function validateIsString(value: any): IValidationResult<string>;
1105
+
1106
+ interface IValidateMaxOptions {
1107
+ limit: any;
1108
+ }
1109
+ declare function validateMax(value: any, options: IValidateMaxOptions): IValidationResult<any>;
1110
+
1111
+ interface IValidateMinOptions {
1112
+ limit: any;
1113
+ }
1114
+ declare function validateMin(value: any, options: IValidateMinOptions): IValidationResult<any>;
1115
+
1116
+ declare function validateIsPresent(value: any): IValidationResult<any>;
1117
+
1118
+ declare function validateModel<V>(value: any, info: IModelValidatorsInfo<V>): IModelValidationResult<V>;
1119
+
1120
+ declare function validateModel2<V>(value: any, modelConstructor: IConstructor<V>): IModelValidationResult<V>;
1121
+
1122
+ 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 };